Catalano.IO
Class CSVParser
- java.lang.Object
-
- Catalano.IO.CSVParser
-
public class CSVParser extends java.lang.ObjectCSV Parser, handle csv files.
-
-
Constructor Summary
Constructors Constructor and Description CSVParser()Initialize a new instance of the CSVParser class.CSVParser(char delimiter)Initialize a new instance of the CSVParser class.CSVParser(char delimiter, int startRow)Initialize a new instance of the CSVParser class.CSVParser(char delimiter, int startRow, int startColumn)Initialize a new instance of the CSVParser class.CSVParser(char delimiter, int startRow, int startColumn, int endColumn)Initialize a new instance of the CSVParser class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description chargetDelimiter()Get the delimiter.intgetEndColumn()Get end column index.java.lang.StringgetNewLine()Get new line separator.intgetStartColumn()Get start column index.intgetStartRow()Get start row index.java.lang.String[][]Read(java.lang.String filename)Read CSV.<T> java.util.List<T>Read(java.lang.String filename, java.lang.Class clazz)Read CSV and convert to object type.double[][]ReadAsDouble(java.lang.String filename)int[][]ReadAsInt(java.lang.String filename)voidsetDelimiter(char delimiter)Set the delimiter.voidsetEndColumn(int endCol)Set end column index.voidsetNewLine(java.lang.String newLine)Set new line separator.voidsetStartColumn(int startCol)Set start column index.voidsetStartRow(int startRow)Set start row index.voidWrite(double[][] data, java.lang.String filename)voidWrite(double[][] data, java.lang.String filename, int decimalPlaces)Write the matrix of integer in csv file format.voidWrite(int[][] data, java.lang.String filename)Write the matrix of integer in csv file format.voidWrite(java.lang.String[][] data, java.lang.String filename)Write the matrix of string in csv file format.
-
-
-
Constructor Detail
-
CSVParser
public CSVParser()
Initialize a new instance of the CSVParser class.
-
CSVParser
public CSVParser(char delimiter)
Initialize a new instance of the CSVParser class.- Parameters:
delimiter- Delimiter.
-
CSVParser
public CSVParser(char delimiter, int startRow)Initialize a new instance of the CSVParser class.- Parameters:
delimiter- Delimiter.startRow- Start row.
-
CSVParser
public CSVParser(char delimiter, int startRow, int startColumn)Initialize a new instance of the CSVParser class.- Parameters:
delimiter- Delimiter.startRow- Start row.startColumn- Start column.
-
CSVParser
public CSVParser(char delimiter, int startRow, int startColumn, int endColumn)Initialize a new instance of the CSVParser class.- Parameters:
delimiter- Delimiter.startRow- Start row.startColumn- Start column.endColumn- End column.
-
-
Method Detail
-
getDelimiter
public char getDelimiter()
Get the delimiter.- Returns:
- Delimiter.
-
setDelimiter
public void setDelimiter(char delimiter)
Set the delimiter.- Parameters:
delimiter- Delimiter.
-
getNewLine
public java.lang.String getNewLine()
Get new line separator.- Returns:
- New line separator.
-
setNewLine
public void setNewLine(java.lang.String newLine)
Set new line separator.- Parameters:
newLine- New line separator.
-
getStartRow
public int getStartRow()
Get start row index.- Returns:
- Start row index.
-
setStartRow
public void setStartRow(int startRow)
Set start row index.- Parameters:
startRow- Start row index.
-
getStartColumn
public int getStartColumn()
Get start column index.- Returns:
- Start column index.
-
setStartColumn
public void setStartColumn(int startCol)
Set start column index.- Parameters:
startCol- Start column index.
-
getEndColumn
public int getEndColumn()
Get end column index. Default: -1, It means to get all columns.- Returns:
-
setEndColumn
public void setEndColumn(int endCol)
Set end column index. Value: -1 for to set the last column.- Parameters:
endCol- End column index.
-
Read
public <T> java.util.List<T> Read(java.lang.String filename, java.lang.Class clazz)Read CSV and convert to object type. The method find the constructor that contains the maximum parameters.- Type Parameters:
T- Object type.- Parameters:
filename- CSV filename.clazz- Object type.- Returns:
- List of user definied type.
-
Read
public java.lang.String[][] Read(java.lang.String filename)
Read CSV.- Parameters:
filename- Filename.- Returns:
- CSV table of string.
-
ReadAsDouble
public double[][] ReadAsDouble(java.lang.String filename)
-
ReadAsInt
public int[][] ReadAsInt(java.lang.String filename)
-
Write
public void Write(java.lang.String[][] data, java.lang.String filename)Write the matrix of string in csv file format.- Parameters:
data- Data.filename- Filename.
-
Write
public void Write(int[][] data, java.lang.String filename)Write the matrix of integer in csv file format.- Parameters:
data- Data.filename- Filename.
-
Write
public void Write(double[][] data, java.lang.String filename)
-
Write
public void Write(double[][] data, java.lang.String filename, int decimalPlaces)Write the matrix of integer in csv file format.- Parameters:
data- Data.filename- Filename.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG