Class CsvTools
java.lang.Object
com.illumon.iris.db.tables.utils.csv.CsvTools
public class CsvTools extends Object
Util class that supports and handles the changes needed to migrate to new dhc-fast-csv parser.
-
Constructor Summary
Constructors Constructor Description CsvTools()
-
Method Summary
Modifier and Type Method Description static List<String>
getColumnHeaders(InputStream stream, io.deephaven.csv.CsvSpecs specs)
Return the column headers as list using the values from the first row.static io.deephaven.csv.CsvSpecs.Builder
getCsvSpecsBuilder(String format, boolean hasHeader, Collection<String> headers)
Returns the CsvSpecs.Builder created with appropriate properties.static Table
readCsv(InputStream stream, String format, boolean v2, StatusCallback progress, boolean noHeader, Collection<String> header)
Creates an in-memory table fromstream
by importing CSV data according to thespecs
.
-
Constructor Details
-
CsvTools
public CsvTools()
-
-
Method Details
-
getColumnHeaders
@NotNull public static List<String> getColumnHeaders(@NotNull InputStream stream, @NotNull io.deephaven.csv.CsvSpecs specs) throws IOExceptionReturn the column headers as list using the values from the first row. To avoid reading the entire file the CsvSpecs should restrict the num of rows to be read to 1, this check is enforced.- Parameters:
stream
- An InputStream providing access to the CSV data.specs
- The CsvSpecs- Returns:
- Return the column headers using the values from the first row.
- Throws:
IOException
-
readCsv
public static Table readCsv(InputStream stream, String format, boolean v2, StatusCallback progress, boolean noHeader, @Nullable Collection<String> header) throws IOExceptionCreates an in-memory table fromstream
by importing CSV data according to thespecs
. Thestream
will be closed upon return.- Parameters:
stream
- an InputStream providing access to the CSV data.format
- can be null a delimiter or one of DEFAULT, TDF, EXCEL, MYSQL, RFC4180 and TRIMv2
- whether the process imports using the older QueryTable processing (v2 = true) or the newer InMemoryTable processing (v2 = false).progress
- a StatusCallback object that can be used to log progress details or update a progress bar. If passed explicitly as null, a StatusCallback instance will be created to log progress to the current logger.noHeader
- boolean indicates if data contains headerheader
- Column names to use as, or instead of, the header row for the CSV.- Returns:
- a Deephaven Table object
- Throws:
IOException
-
getCsvSpecsBuilder
@Nullable public static io.deephaven.csv.CsvSpecs.Builder getCsvSpecsBuilder(@Nullable String format, boolean hasHeader, @Nullable Collection<String> headers)Returns the CsvSpecs.Builder created with appropriate properties.- Parameters:
format
- can be null a delimiter or one of DEFAULT, TDF, EXCEL, MYSQL, RFC4180 and TRIMhasHeader
- true or false to indicate if data includes header rowheaders
- Column names to use as, or instead of, the header row for the CSV.- Returns:
- CsvSpecs.Builder
-