org.encog.util.csv
Class ReadCSV
- java.lang.Object
-
- org.encog.util.csv.ReadCSV
-
public class ReadCSV extends java.lang.ObjectRead and parse CSV format files.
-
-
Constructor Summary
Constructors Constructor and Description ReadCSV(java.io.File file, boolean headers, char delim)Construct a CSV reader from a filename.ReadCSV(java.io.File file, boolean headers, CSVFormat format)Construct a CSV reader from a filename.ReadCSV(java.io.InputStream is, boolean headers, char delim)Construct a CSV reader from an input stream.ReadCSV(java.io.InputStream is, boolean headers, CSVFormat format)Construct a CSV reader from an input stream.ReadCSV(java.lang.String filename, boolean headers, char delim)ReadCSV(java.lang.String filename, boolean headers, CSVFormat format)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()Close the file.static java.lang.StringdisplayDate(java.util.Date date)Format a date.java.lang.Stringget(int i)Get the specified column as a string.java.lang.Stringget(java.lang.String column)Get the column by its string name, as a string.intgetColumnCount()Get the column count.java.util.List<java.lang.String>getColumnNames()java.util.DategetDate(java.lang.String column)Get the column as a date.doublegetDouble(int index)Get the column as a double specified by index.doublegetDouble(java.lang.String column)Get the specified column as a double.CSVFormatgetFormat()intgetInt(int i)Obtain a column as an integer referenced by a string.booleanhasMissing()booleannext()Read the next line.static java.util.DateparseDate(java.lang.String when)Parse a date.
-
-
-
Constructor Detail
-
ReadCSV
public ReadCSV(java.io.InputStream is, boolean headers, char delim)Construct a CSV reader from an input stream. Allows a delimiter character to be specified. Numbers will be parsed using the current locale.- Parameters:
is- The InputStream to read from.headers- Are headers present?delim- What is the delimiter.
-
ReadCSV
public ReadCSV(java.io.InputStream is, boolean headers, CSVFormat format)Construct a CSV reader from an input stream. The format parameter specifies the separator character to use, as well as the number format.- Parameters:
is- The InputStream to read from.headers- Are headers present?format- What is the CSV format.
-
ReadCSV
public ReadCSV(java.io.File file, boolean headers, char delim)Construct a CSV reader from a filename. The format parameter specifies the separator character to use, as well as the number format.- Parameters:
file- The file.headers- The headers.delim- The delimiter.
-
ReadCSV
public ReadCSV(java.lang.String filename, boolean headers, char delim)
-
ReadCSV
public ReadCSV(java.lang.String filename, boolean headers, CSVFormat format)
-
ReadCSV
public ReadCSV(java.io.File file, boolean headers, CSVFormat format)Construct a CSV reader from a filename. Allows a delimiter character to be specified.- Parameters:
file- The file.headers- The headers.format- The format.
-
-
Method Detail
-
displayDate
public static java.lang.String displayDate(java.util.Date date)
Format a date.- Parameters:
date- The date to format.- Returns:
- The formatted date.
-
parseDate
public static java.util.Date parseDate(java.lang.String when)
Parse a date.- Parameters:
when- The date string.- Returns:
- The parsed date.
-
close
public void close()
Close the file.
-
get
public java.lang.String get(int i)
Get the specified column as a string.- Parameters:
i- The column index, starting at zero.- Returns:
- The column as a string.
-
get
public java.lang.String get(java.lang.String column)
Get the column by its string name, as a string. This will only work if column headers were defined that have string names.- Parameters:
column- The column name.- Returns:
- The column data as a string.
-
getColumnCount
public int getColumnCount()
Get the column count.- Returns:
- The column count.
-
getDate
public java.util.Date getDate(java.lang.String column)
Get the column as a date.- Parameters:
column- The column header name.- Returns:
- The column as a date.
-
getDouble
public double getDouble(int index)
Get the column as a double specified by index.- Parameters:
index- The column index, starting at zero.- Returns:
- The data at the specified column.
-
getDouble
public double getDouble(java.lang.String column)
Get the specified column as a double.- Parameters:
column- The column name that we want to get.- Returns:
- The column data as a double.
-
getInt
public int getInt(int i)
Obtain a column as an integer referenced by a string.- Parameters:
i- The column header name being read.- Returns:
- The column data as an integer.
-
next
public boolean next()
Read the next line.- Returns:
- True if there are more lines to read.
-
getColumnNames
public java.util.List<java.lang.String> getColumnNames()
-
getFormat
public CSVFormat getFormat()
-
hasMissing
public boolean hasMissing()
-
-
DMelt 3.0 © DataMelt by jWork.ORG