@Immutable public class FixedWidthReader extends FileReader
Constructor and Description |
---|
FixedWidthReader()
Constructs a FixedWidthReader
|
FixedWidthReader(List<ColumnType> typeDetectionList)
Constructs a FixedWidthReader with the given list of ColumnTypes
|
Modifier and Type | Method and Description |
---|---|
ColumnType[] |
detectColumnTypes(Reader reader,
FixedWidthReadOptions options)
Estimates and returns the type for each column in the delimited text file
file |
String |
printColumnTypes(FixedWidthReadOptions options)
Returns a string representation of the column types in file
fixed widthFilename ,
as determined by the type-detection algorithm |
Table |
read(FixedWidthReadOptions options) |
getTypes, getTypeString, parseRows
public FixedWidthReader()
public FixedWidthReader(List<ColumnType> typeDetectionList)
These are the only types that the FixedWidthReader can detect and parse
public Table read(FixedWidthReadOptions options) throws IOException
IOException
public String printColumnTypes(FixedWidthReadOptions options) throws IOException
fixed widthFilename
,
as determined by the type-detection algorithm
This 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:
IOException
- if file cannot be readpublic ColumnType[] detectColumnTypes(Reader reader, FixedWidthReadOptions options)
file
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.
Copyright © 2019. All rights reserved.