Class FixedWidthReader
- java.lang.Object
-
- tech.tablesaw.io.FileReader
-
- tech.tablesaw.io.fixed.FixedWidthReader
-
- All Implemented Interfaces:
DataReader<FixedWidthReadOptions>
@Immutable public class FixedWidthReader extends FileReader implements DataReader<FixedWidthReadOptions>
-
-
Constructor Summary
Constructors Constructor Description FixedWidthReader()
Constructs a FixedWidthReader
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ColumnType[]
detectColumnTypes(Reader reader, FixedWidthReadOptions options)
Estimates and returns the type for each column in the delimited text filefile
String
printColumnTypes(FixedWidthReadOptions options)
Returns a string representation of the column types in filefixed widthFilename
, as determined by the type-detection algorithmTable
read(FixedWidthReadOptions options)
Table
read(Source source)
static void
register(ReaderRegistry registry)
-
Methods inherited from class tech.tablesaw.io.FileReader
getColumnNames, getColumnTypes, getTypeString, parseRows, parseRows
-
-
-
-
Method Detail
-
register
public static void register(ReaderRegistry registry)
-
read
public Table read(FixedWidthReadOptions options)
- Specified by:
read
in interfaceDataReader<FixedWidthReadOptions>
-
printColumnTypes
public String printColumnTypes(FixedWidthReadOptions options)
Returns a string representation of the column types in filefixed widthFilename
, as determined by the type-detection algorithmThis method is intended to help analysts quickly fix any erroneous types, by printing out the types in a format such that they can be edited to correct any mistakes, and used in an array literal
For example:
LOCAL_DATE, // 0 date SHORT, // 1 approval STRING, // 2 who
Note that the types are array separated, and that the index position and the column name are printed such that they would be interpreted as comments if you paste the output into an array:
-
detectColumnTypes
public ColumnType[] detectColumnTypes(Reader reader, FixedWidthReadOptions options)
Estimates and returns the type for each column in the delimited text filefile
The type is determined by checking a sample of the data in the file. Because only a sample of the data is checked, the types may be incorrect. If that is the case a Parse Exception will be thrown.
The method
printColumnTypes()
can be used to print a list of the detected columns that can be corrected and used to explicitly specify the correct column types.
-
read
public Table read(Source source)
- Specified by:
read
in interfaceDataReader<FixedWidthReadOptions>
-
-