public class ColumnTypeDetector extends Object
| Constructor and Description |
|---|
ColumnTypeDetector(List<ColumnType> typeArray) |
| Modifier and Type | Method and Description |
|---|---|
ColumnType[] |
detectColumnTypes(Iterator<String[]> rows,
ReadOptions options)
Estimates and returns the type for each column in the input text
|
public ColumnTypeDetector(List<ColumnType> typeArray)
typeArray - Types to choose from. When more than one would work, we pick the first of
the options. The order these appear in is critical. The broadest must go last, so String
must be at the end of the list. Any String read from the input will match string. If it
were first on the list, you would get nothing but strings in your table. As another example,
an integer type, should go before double. Otherwise double would match integers so the
integer test would never be evaluated and all the ints would be read as doubles.public ColumnType[] detectColumnTypes(Iterator<String[]> rows, ReadOptions options)
The type is determined by checking a sample of the data. 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.