Package io.deephaven.csv
Class CsvTools
java.lang.Object
io.deephaven.csv.CsvTools
Utilities for reading and writing CSV files to and from
Tables-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic io.deephaven.csv.CsvSpecs.Builderbuilder()Creates aCsvSpecs.BuilderwithCsvTools-specific values.static io.deephaven.csv.CsvSpecsfromLegacyFormat(String format) static TablereadCsv(InputStream stream) Creates an in-memory table fromstreamby importing CSV data.static TablereadCsv(InputStream is, char separator) Deprecated.static TablereadCsv(InputStream stream, io.deephaven.csv.CsvSpecs specs) Creates an in-memory table fromstreamby importing CSV data according to thespecs.static TablereadCsv(InputStream is, String format) Deprecated.static TableCreates an in-memory table frompathby importing CSV data.static TableCreates an in-memory table frompathby importing CSV data according to thespecs.static TableCreates an in-memory table fromurlby importing CSV data.static TableCreates an in-memory table fromurlby importing CSV data according to thespecs.static TableCreates an in-memory table frompathby importing CSV data.static TableCreates an in-memory table frompathby importing CSV data according to thespecs.static TablereadHeaderlessCsv(String filePath, String... columnNames) Equivalent toCsvTools.readCsv(filePath, CsvTools.builder().hasHeaderRow(false).build()).renameColumns(renamesForHeaderless(columnNames));static TablereadHeaderlessCsv(String filePath, Collection<String> columnNames) Equivalent toCsvTools.readCsv(filePath, CsvTools.builder().hasHeaderRow(false).build()).renameColumns(renamesForHeaderless(columnNames));static Collection<Pair>renamesForHeaderless(String... columnNames) Convert an array of column names to use for a result table into a series ofrename pairsto pass toTable.renameColumns(Collection).static Collection<Pair>renamesForHeaderless(Collection<String> columnNames) Convert an ordered collection of column names to use for a result table into a series ofrename pairsto pass toTable.renameColumns(Collection).protected static StringseparatorCsvEscape(String str, String separator) Returns a String value for a CSV column's value.static voidwriteCsv(Table[] sources, String destPath, boolean compressed, ZoneId timeZone, String tableSeparator, boolean nullsAsEmpty, String... columns) Writes a table out as a CSV.static voidwriteCsv(Table[] sources, String destPath, boolean compressed, ZoneId timeZone, String tableSeparator, char fieldSeparator, boolean nullsAsEmpty, String... columns) Writes a table out as a CSV.static voidwriteCsv(Table[] sources, String destPath, boolean compressed, ZoneId timeZone, String tableSeparator, String... columns) Writes a table out as a CSV.static voidwriteCsv(Table source, boolean compressed, String destPath, boolean nullsAsEmpty, String... columns) Writes a table out as a CSV.static voidWrites a table out as a CSV.static voidwriteCsv(Table source, PrintStream out, boolean nullsAsEmpty, String... columns) Writes a table out as a CSV.static voidwriteCsv(Table source, PrintStream out, String... columns) Writes a table out as a CSV.static voidwriteCsv(Table source, Writer out, ZoneId timeZone, @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, char separator, String... columns) Writes a table out as a CSV file.static voidwriteCsv(Table source, Writer out, ZoneId timeZone, @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, String... columns) Writes a table out as a CSV file.static voidWrites a table out as a CSV.static voidwriteCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, boolean nullsAsEmpty, char separator, String... columns) Writes a table out as a CSV.static voidwriteCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, boolean nullsAsEmpty, String... columns) Writes a table out as a CSV.static voidwriteCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, char separator, String... columns) Writes a table out as a CSV file.static voidwriteCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, String... columns) Writes a table out as a CSV file.static voidwriteCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, @Nullable BiConsumer<Long, Long> progress, String... columns) Writes a table out as a CSV file.static voidWrites a table out as a CSV.static voidWrites a table out as a CSV.static voidwriteCsvContents(Table source, Writer out, ZoneId timeZone, boolean nullsAsEmpty, String... colNames) Writes a table out as a CSV file.static voidwriteCsvContents(Table source, Writer out, ZoneId timeZone, @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, char separator, String... colNames) Writes a table out as a CSV file.static voidwriteCsvContents(Table source, Writer out, ZoneId timeZone, @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, String... colNames) Writes a table out as a CSV file.static voidwriteCsvContents(Table source, Writer out, ZoneId timeZone, @Nullable BiConsumer<Long, Long> progress, String... colNames) Writes a table out as a CSV file.static voidwriteCsvContents(Table source, Writer out, ZoneId timeZone, String... colNames) Writes a table out as a CSV file.static voidwriteCsvHeader(Writer out, char separator, String... columns) Writes the column name header row to a CSV file.static voidwriteCsvHeader(Writer out, String... columns) Writes the column name header row to a CSV file.static voidwriteCsvPaginate(Table source, String destPath, String filename) Writes a Deephaven table to one or more files, splitting it based on the MAX_CSV_LINE_COUNT setting.static voidwriteCsvPaginate(Table source, String destPath, String filename, boolean nullsAsEmpty) Writes a Deephaven table to one or more files, splitting it based on the MAX_CSV_LINE_COUNT setting.static voidwriteToMultipleFiles(Table table, String path, String filename, long startLine) Writes a subset of rows from a Deephaven table to a CSV file.static voidwriteToMultipleFiles(Table table, String path, String filename, long startLine, boolean nullsAsEmpty) Writes a subset of rows from a Deephaven table to a CSV file.
-
Field Details
-
MAX_CSV_LINE_COUNT
public static final int MAX_CSV_LINE_COUNT- See Also:
-
NULLS_AS_EMPTY_DEFAULT
public static final boolean NULLS_AS_EMPTY_DEFAULT- See Also:
-
-
Constructor Details
-
CsvTools
public CsvTools()
-
-
Method Details
-
builder
public static io.deephaven.csv.CsvSpecs.Builder builder()Creates aCsvSpecs.BuilderwithCsvTools-specific values. SetsColumnNameLegalizer.INSTANCEasCsvSpecs.Builder.headerLegalizer(Function)andCsvSpecs.Builder.headerValidator(Predicate); sets a new instance ofDeephavenTimeZoneParserasCsvSpecs.Builder.customTimeZoneParser(CustomTimeZoneParser).- Returns:
- the builder
-
readCsv
Creates an in-memory table frompathby importing CSV data.If
pathis a non-fileURL, the CSV will be parsed viareadCsv(URL, CsvSpecs).Otherwise, the
pathwill be parsed viareadCsv(Path, CsvSpecs), which will apply decompression based on thepath.- Parameters:
path- the path- Returns:
- the table
- Throws:
io.deephaven.csv.util.CsvReaderException- See Also:
-
readCsv
@ScriptApi public static Table readCsv(InputStream stream) throws io.deephaven.csv.util.CsvReaderException Creates an in-memory table fromstreamby importing CSV data. Thestreamwill be closed upon return.- Parameters:
stream- an InputStream providing access to the CSV data.- Returns:
- a Deephaven Table object
- Throws:
io.deephaven.csv.util.CsvReaderException- See Also:
-
readCsv
Creates an in-memory table fromurlby importing CSV data.- Parameters:
url- the url- Returns:
- the table
- Throws:
io.deephaven.csv.util.CsvReaderException- See Also:
-
readCsv
Creates an in-memory table frompathby importing CSV data.Paths that end in ".tar.zip", ".tar.bz2", ".tar.gz", ".tar.7z", ".tar.zst", ".zip", ".bz2", ".gz", ".7z", ".zst", or ".tar" will be decompressed.
- Parameters:
path- the file path- Returns:
- the table
- Throws:
io.deephaven.csv.util.CsvReaderException- See Also:
-
readCsv
@ScriptApi public static Table readCsv(String path, io.deephaven.csv.CsvSpecs specs) throws io.deephaven.csv.util.CsvReaderException Creates an in-memory table frompathby importing CSV data according to thespecs.If
pathis a non-fileURL, the CSV will be parsed viareadCsv(URL, CsvSpecs).Otherwise, the
pathwill be parsed viareadCsv(Path, CsvSpecs), which will apply decompression based on thepath.- Parameters:
path- the pathspecs- the csv specs- Returns:
- the table
- Throws:
io.deephaven.csv.util.CsvReaderException- See Also:
-
readCsv
@ScriptApi public static Table readCsv(InputStream stream, io.deephaven.csv.CsvSpecs specs) throws io.deephaven.csv.util.CsvReaderException Creates an in-memory table fromstreamby importing CSV data according to thespecs. Thestreamwill be closed upon return.- Parameters:
stream- The streamspecs- The CSV specs.- Returns:
- The table.
- Throws:
io.deephaven.csv.util.CsvReaderException- If some error occurs.
-
readCsv
@ScriptApi public static Table readCsv(URL url, io.deephaven.csv.CsvSpecs specs) throws io.deephaven.csv.util.CsvReaderException Creates an in-memory table fromurlby importing CSV data according to thespecs.- Parameters:
url- the urlspecs- the csv specs- Returns:
- the table
- Throws:
io.deephaven.csv.util.CsvReaderException- If some CSV reading error occurs.
-
readCsv
@ScriptApi public static Table readCsv(Path path, io.deephaven.csv.CsvSpecs specs) throws io.deephaven.csv.util.CsvReaderException Creates an in-memory table frompathby importing CSV data according to thespecs.A
paththat ends in ".tar.zip", ".tar.bz2", ".tar.gz", ".tar.7z", ".tar.zst", ".zip", ".bz2", ".gz", ".7z", ".zst", or ".tar" will be decompressed.- Parameters:
path- the pathspecs- the csv specs- Returns:
- the table
- Throws:
io.deephaven.csv.util.CsvReaderException- If some CSV reading error occurs.- See Also:
-
renamesForHeaderless
Convert an ordered collection of column names to use for a result table into a series ofrename pairsto pass toTable.renameColumns(Collection).- Parameters:
columnNames- The column names- Returns:
- A collection of
rename columns
-
renamesForHeaderless
Convert an array of column names to use for a result table into a series ofrename pairsto pass toTable.renameColumns(Collection).- Parameters:
columnNames- The column names- Returns:
- A collection of
rename columns
-
readHeaderlessCsv
@ScriptApi public static Table readHeaderlessCsv(String filePath, Collection<String> columnNames) throws io.deephaven.csv.util.CsvReaderException Equivalent toCsvTools.readCsv(filePath, CsvTools.builder().hasHeaderRow(false).build()).renameColumns(renamesForHeaderless(columnNames));- Throws:
io.deephaven.csv.util.CsvReaderException
-
readHeaderlessCsv
@ScriptApi public static Table readHeaderlessCsv(String filePath, String... columnNames) throws io.deephaven.csv.util.CsvReaderException Equivalent toCsvTools.readCsv(filePath, CsvTools.builder().hasHeaderRow(false).build()).renameColumns(renamesForHeaderless(columnNames));- Throws:
io.deephaven.csv.util.CsvReaderException
-
readCsv
@ScriptApi @Deprecated public static Table readCsv(InputStream is, String format) throws io.deephaven.csv.util.CsvReaderException Deprecated.Creates an in-memory table by importing CSV data. The first row must be column names. Column data types are inferred from the data.- Parameters:
is- an InputStream providing access to the CSV data.format- an Apache Commons CSV format name to be used to parse the CSV, or a single non-newline character to use as a delimiter.- Returns:
- a Deephaven Table object
- Throws:
io.deephaven.csv.util.CsvReaderException
-
readCsv
@ScriptApi @Deprecated public static Table readCsv(InputStream is, char separator) throws io.deephaven.csv.util.CsvReaderException Deprecated.Creates an in-memory table by importing CSV data. The first row must be column names. Column data types are inferred from the data.- Parameters:
is- an InputStream providing access to the CSV data.separator- a char to use as the delimiter value when parsing the file.- Returns:
- a Deephaven Table object
- Throws:
io.deephaven.csv.util.CsvReaderException
-
writeCsv
@ScriptApi public static void writeCsv(Table source, boolean compressed, String destPath, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
source- a Deephaven table object to be exporteddestPath- path to the CSV file to be writtencompressed- whether to compress (bz2) the file being writtencolumns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, boolean compressed, String destPath, boolean nullsAsEmpty, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
source- a Deephaven table object to be exporteddestPath- path to the CSV file to be writtencompressed- whether to compress (bz2) the file being writtennullsAsEmpty- if nulls should be written as blank instead of '(null)'columns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
source- a Deephaven table object to be exporteddestPath- path to the CSV file to be writtencolumns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean nullsAsEmpty, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
source- a Deephaven table object to be exporteddestPath- path to the CSV file to be writtennullsAsEmpty- if nulls should be written as blank instead of '(null)'columns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, PrintStream out, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
source- a Deephaven table object to be exportedout- the stream to write tocolumns- a list of columns to include in the export- Throws:
IOException- if there is a problem writing to the stream
-
writeCsv
@ScriptApi public static void writeCsv(Table source, PrintStream out, boolean nullsAsEmpty, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
source- a Deephaven table object to be exportedout- the stream to write tonullsAsEmpty- if nulls should be written as blank instead of '(null)'columns- a list of columns to include in the export- Throws:
IOException- if there is a problem writing to the stream
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
source- a Deephaven table object to be exporteddestPath- path to the CSV file to be writtencompressed- whether to zip the file being writtentimeZone- a time zone constant relative to which date time data should be adjustedcolumns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, boolean nullsAsEmpty, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
source- a Deephaven table object to be exporteddestPath- path to the CSV file to be writtencompressed- whether to zip the file being writtentimeZone- a time zone constant relative to which date time data should be adjustednullsAsEmpty- if nulls should be written as blank instead of '(null)'columns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, boolean nullsAsEmpty, char separator, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
source- a Deephaven table object to be exporteddestPath- path to the CSV file to be writtencompressed- whether to zip the file being writtentimeZone- a time zone constant relative to which date time data should be adjustednullsAsEmpty- if nulls should be written as blank instead of '(null)'separator- the delimiter for the CSVcolumns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table[] sources, String destPath, boolean compressed, ZoneId timeZone, String tableSeparator, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
sources- an array of Deephaven table objects to be exporteddestPath- path to the CSV file to be writtencompressed- whether to compress (bz2) the file being writtentimeZone- a time zone constant relative to which date time data should be adjustedtableSeparator- a String (normally a single character) to be used as the table delimitercolumns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table[] sources, String destPath, boolean compressed, ZoneId timeZone, String tableSeparator, boolean nullsAsEmpty, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
sources- an array of Deephaven table objects to be exporteddestPath- path to the CSV file to be writtencompressed- whether to compress (bz2) the file being writtentimeZone- a time zone constant relative to which date time data should be adjustedtableSeparator- a String (normally a single character) to be used as the table delimitercolumns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table[] sources, String destPath, boolean compressed, ZoneId timeZone, String tableSeparator, char fieldSeparator, boolean nullsAsEmpty, String... columns) throws IOException Writes a table out as a CSV.- Parameters:
sources- an array of Deephaven table objects to be exporteddestPath- path to the CSV file to be writtencompressed- whether to compress (bz2) the file being writtentimeZone- a time zone constant relative to which date time data should be adjustedtableSeparator- a String (normally a single character) to be used as the table delimiterfieldSeparator- the delimiter for the CSV filesnullsAsEmpty- if nulls should be written as blank instead of '(null)'columns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, @Nullable @Nullable BiConsumer<Long, Long> progress, String... columns) throws IOExceptionWrites a table out as a CSV file.- Parameters:
source- a Deephaven table object to be exporteddestPath- path to the CSV file to be writtencompressed- whether to zip the file being writtentimeZone- a time zone constant relative to which date time data should be adjustedprogress- a procedure that implements BiConsumer, and takes a progress Integer and a total size Integer to update progresscolumns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, @Nullable @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, String... columns) throws IOExceptionWrites a table out as a CSV file.- Parameters:
source- a Deephaven table object to be exporteddestPath- path to the CSV file to be writtencompressed- whether to zip the file being writtentimeZone- a time zone constant relative to which date time data should be adjustedprogress- a procedure that implements BiConsumer, and takes a progress Integer and a total size Integer to update progressnullsAsEmpty- if nulls should be written as blank instead of '(null)'columns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean compressed, ZoneId timeZone, @Nullable @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, char separator, String... columns) throws IOExceptionWrites a table out as a CSV file.- Parameters:
source- a Deephaven table object to be exporteddestPath- path to the CSV file to be writtencompressed- whether to zip the file being writtentimeZone- a time zone constant relative to which date time data should be adjustedprogress- a procedure that implements BiConsumer, and takes a progress Integer and a total size Integer to update progressnullsAsEmpty- if nulls should be written as blank instead of '(null)'separator- the delimiter for the CSVcolumns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, Writer out, ZoneId timeZone, @Nullable @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, String... columns) throws IOExceptionWrites a table out as a CSV file.- Parameters:
source- a Deephaven table object to be exportedout- Writer used to write the CSVtimeZone- a time zone constant relative to which date time data should be adjustedprogress- a procedure that implements BiConsumer, and takes a progress Integer and a total size Integer to update progressnullsAsEmpty- if nulls should be written as blank instead of '(null)'columns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, Writer out, ZoneId timeZone, @Nullable @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, char separator, String... columns) throws IOExceptionWrites a table out as a CSV file.- Parameters:
source- a Deephaven table object to be exportedout- Writer used to write the CSVtimeZone- a time zone constant relative to which date time data should be adjustedprogress- a procedure that implements BiConsumer, and takes a progress Integer and a total size Integer to update progressnullsAsEmpty- if nulls should be written as blank instead of '(null)'separator- the delimiter for the CSVcolumns- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsvHeader
Writes the column name header row to a CSV file.- Parameters:
out- the Writer to which the header should be writtencolumns- a list of column names to be written- Throws:
IOException- if the Writer cannot be written to
-
writeCsvHeader
@ScriptApi public static void writeCsvHeader(Writer out, char separator, String... columns) throws IOException Writes the column name header row to a CSV file.- Parameters:
out- the Writer to which the header should be writtenseparator- a char to use as the delimiter value when writing out the headercolumns- a list of column names to be written- Throws:
IOException- if the Writer cannot be written to
-
writeCsvPaginate
@ScriptApi public static void writeCsvPaginate(Table source, String destPath, String filename) throws IOException Writes a Deephaven table to one or more files, splitting it based on the MAX_CSV_LINE_COUNT setting.- Parameters:
source- a Deephaven table to be exporteddestPath- the path in which the CSV file(s) should be writtenfilename- the base file name to use for the files. A dash and starting line number will be concatenated to each file.- Throws:
IOException- if the destination files cannot be written
-
writeCsvPaginate
@ScriptApi public static void writeCsvPaginate(Table source, String destPath, String filename, boolean nullsAsEmpty) throws IOException Writes a Deephaven table to one or more files, splitting it based on the MAX_CSV_LINE_COUNT setting.- Parameters:
source- a Deephaven table to be exporteddestPath- the path in which the CSV file(s) should be writtenfilename- the base file name to use for the files. A dash and starting line number will be concatenated to each file.nullsAsEmpty- if nulls should be written as blank instead of '(null)'- Throws:
IOException- if the destination files cannot be written
-
writeToMultipleFiles
@ScriptApi public static void writeToMultipleFiles(Table table, String path, String filename, long startLine) throws IOException Writes a subset of rows from a Deephaven table to a CSV file.- Parameters:
table- a Deephaven table from which rows should be exportedpath- the destination path in which the output CSV file should be createdfilename- the base file name to which a dash and starting line number will be concatenated for the filestartLine- the starting line number from the table to export; the ending line number will be startLine + MAX_CSV_LINE_COUNT-1, or the end of the table- Throws:
IOException- if the destination file cannot be written
-
writeToMultipleFiles
@ScriptApi public static void writeToMultipleFiles(Table table, String path, String filename, long startLine, boolean nullsAsEmpty) throws IOException Writes a subset of rows from a Deephaven table to a CSV file.- Parameters:
table- a Deephaven table from which rows should be exportedpath- the destination path in which the output CSV file should be createdfilename- the base file name to which a dash and starting line number will be concatenated for the filestartLine- the starting line number from the table to export; the ending line number will be startLine + MAX_CSV_LINE_COUNT-1, or the end of the tablenullsAsEmpty- if nulls should be written as blank instead of '(null)'- Throws:
IOException- if the destination file cannot be written
-
writeCsvContents
@ScriptApi public static void writeCsvContents(Table source, Writer out, ZoneId timeZone, String... colNames) throws IOException Writes a table out as a CSV file.- Parameters:
source- a Deephaven table object to be exportedout- a Writer to which the header should be writtentimeZone- a time zone constant relative to which date time data should be adjustedcolNames- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsvContents
@ScriptApi public static void writeCsvContents(Table source, Writer out, ZoneId timeZone, boolean nullsAsEmpty, String... colNames) throws IOException Writes a table out as a CSV file.- Parameters:
source- a Deephaven table object to be exportedout- a Writer to which the header should be writtentimeZone- a time zone constant relative to which date time data should be adjustednullsAsEmpty- if nulls should be written as blank instead of '(null)'colNames- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsvContents
@ScriptApi public static void writeCsvContents(Table source, Writer out, ZoneId timeZone, @Nullable @Nullable BiConsumer<Long, Long> progress, String... colNames) throws IOExceptionWrites a table out as a CSV file.- Parameters:
source- a Deephaven table object to be exportedout- a Writer to which the header should be writtentimeZone- a time zone constant relative to which date time data should be adjustedprogress- a procedure that implements BiConsumer, and takes a progress Integer and a total size Integer to update progresscolNames- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsvContents
@ScriptApi public static void writeCsvContents(Table source, Writer out, ZoneId timeZone, @Nullable @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, String... colNames) throws IOExceptionWrites a table out as a CSV file.- Parameters:
source- a Deephaven table object to be exportedout- a Writer to which the header should be writtentimeZone- a time zone constant relative to which date time data should be adjustedprogress- a procedure that implements BiConsumer, and takes a progress Integer and a total size Integer to update progressnullsAsEmpty- if nulls should be written as blank instead of '(null)'colNames- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
writeCsvContents
@ScriptApi public static void writeCsvContents(Table source, Writer out, ZoneId timeZone, @Nullable @Nullable BiConsumer<Long, Long> progress, boolean nullsAsEmpty, char separator, String... colNames) throws IOExceptionWrites a table out as a CSV file.- Parameters:
source- a Deephaven table object to be exportedout- a Writer to which the header should be writtentimeZone- a time zone constant relative to which date time data should be adjustedprogress- a procedure that implements BiConsumer, and takes a progress Integer and a total size Integer to update progressnullsAsEmpty- if nulls should be written as blank instead of '(null)'separator- the delimiter for the CSVcolNames- a list of columns to include in the export- Throws:
IOException- if the target file cannot be written
-
separatorCsvEscape
Returns a String value for a CSV column's value. This String will be enclosed in double quotes if the value includes a double quote, a newline, or the separator.- Parameters:
str- the String to be escapedseparator- the delimiter for the CSV- Returns:
- the input String, enclosed in double quotes if the value contains a comma, newline or double quote
-
fromLegacyFormat
-
readCsv(InputStream, CsvSpecs)