readCsv
Read CSV File to DataFrame
Reads any CSV file to a DataFrame.
Note that if input dataframe contains duplicate column names, they will be automatically renamed in the resulting DataFrame.
Parameters you can use to customize the reading process include, for instance, delimiter, header, colTypes, readLines, and parserOptions. See the param list below for all settings.
The integration is built upon Deephaven CSV.
Similar Functions
With the overloads of DataFrame.readCsv(), you can read any CSV by File, Path, URL, or InputStream. Reading by file path or URL can also be done by passing a String.
For example, DataFrame.readCsv("input.csv") or with some options:
file = File("input.csv"),
parserOptions = ParserOptions(locale = Locale.US),
colTypes = mapOf("a" toColType.Int, ColType.DEFAULTtoColType.String),
readLines = 1000L,
)
ZIP (.zip) or GZIP (.gz) files are supported by default. compression is automatically detected.
You can also read "raw" CSV data from a String like this:
DataFrame.readCsvStr("a,b,c", delimiter = ",")
Parameters
The file path to read. Use charset to specify the encoding. Can also be compressed as .gz or .zip, see Compression.
The field delimiter character. Default: ','.
Ignored if hasFixedWidthColumns is true.
The compression of the data. Default: Compression.None, unless detected otherwise from the input file or url.
The character set the input is encoded in. Default: null
If null, the Charset will be read from the BOM of the provided input, defaulting to UTF-8 if no BOM is found.
Whether the data has fixed-width columns instead of a single delimiter. Default: false.
Fixed-width columns can occur, for instance, in multi-space delimited data, where the columns are separated by multiple spaces instead of a single delimiter, so columns are visually aligned. Column widths are determined by the header in the data (if present), or manually by setting fixedColumnWidths.
The fixed column widths. Default: empty list.
Requires hasFixedWidthColumns. If empty, the column widths will be determined by the header in the data (if present), else, this manually sets the column widths. The number of widths should match the number of columns.
The expected ColType per column name. Default: empty map, a.k.a. infer every column type.
If supplied for a certain column name (inferred from data or given by header), the parser will parse the column with the specified name as the specified type, else it will infer the type.
e.g. colTypes = mapOf("colName" toColType.Int). You can also set ColType.DEFAULTtoColType.X to set a default column type, like ColType.String.
The number of lines to skip before reading the header and data. Default: 0.
Useful for files with metadata, or comments at the beginning, or to give a custom header.
The maximum number of lines to read from the data. Default: null.
If null, all lines will be read.
Optional parsing options for columns initially read as String. Default: null.
Can configure locale, date format, double parsing, skipping types, etc.
If parserOptions or any of the arguments are null, the global parser configuration (org.jetbrains.kotlinx.dataframe.DataFrame.Companion.parser) will be queried.
The only exceptions are:
nullStrings, which, ifnull, will take the global setting +["", "NA", "N/A", "null", "NULL", "None", "none", "NIL", "nil"].skipTypes, which will always addtypesDeephavenAlreadyParsesto the given types or the global setting.
Whether to skip intermediate empty lines. Default: false.
If false, empty lines will be interpreted as having empty values if allowMissingColumns.
Whether to allow rows with fewer columns than the header. Default: true.
If true, rows that are too short will be interpreted as empty values.
Whether to ignore rows with more columns than the header. Default: true.
If true, rows that are too long will have those columns dropped.
The quote character. Default: ".
Used when field- or line delimiters should be interpreted as literal text.
For example: 123,"hello, there",456, would correspond to: 123; hello, there; 456.
Whether to ignore leading and trailing blanks around non-quoted fields. Default: true.
Whether to ignore leading and trailing blanks inside quoted fields. Default: false.
Whether to parse the data in parallel. Default: true.
If true, the data will be read and parsed in parallel by the Deephaven parser. This is usually faster but can be turned off for debugging.
Read CSV File to DataFrame
Reads any CSV file to a DataFrame.
Note that if input dataframe contains duplicate column names, they will be automatically renamed in the resulting DataFrame.
Parameters you can use to customize the reading process include, for instance, delimiter, header, colTypes, readLines, and parserOptions. See the param list below for all settings.
The integration is built upon Deephaven CSV.
Similar Functions
With the overloads of DataFrame.readCsv(), you can read any CSV by File, Path, URL, or InputStream. Reading by file path or URL can also be done by passing a String.
For example, DataFrame.readCsv("input.csv") or with some options:
file = File("input.csv"),
parserOptions = ParserOptions(locale = Locale.US),
colTypes = mapOf("a" toColType.Int, ColType.DEFAULTtoColType.String),
readLines = 1000L,
)
ZIP (.zip) or GZIP (.gz) files are supported by default. compression is automatically detected.
You can also read "raw" CSV data from a String like this:
DataFrame.readCsvStr("a,b,c", delimiter = ",")
Parameters
The file to read. Use charset to specify the encoding. Can also be compressed as .gz or .zip, see Compression.
The field delimiter character. Default: ','.
Ignored if hasFixedWidthColumns is true.
The compression of the data. Default: Compression.None, unless detected otherwise from the input file or url.
The character set the input is encoded in. Default: null
If null, the Charset will be read from the BOM of the provided input, defaulting to UTF-8 if no BOM is found.
Whether the data has fixed-width columns instead of a single delimiter. Default: false.
Fixed-width columns can occur, for instance, in multi-space delimited data, where the columns are separated by multiple spaces instead of a single delimiter, so columns are visually aligned. Column widths are determined by the header in the data (if present), or manually by setting fixedColumnWidths.
The fixed column widths. Default: empty list.
Requires hasFixedWidthColumns. If empty, the column widths will be determined by the header in the data (if present), else, this manually sets the column widths. The number of widths should match the number of columns.
The expected ColType per column name. Default: empty map, a.k.a. infer every column type.
If supplied for a certain column name (inferred from data or given by header), the parser will parse the column with the specified name as the specified type, else it will infer the type.
e.g. colTypes = mapOf("colName" toColType.Int). You can also set ColType.DEFAULTtoColType.X to set a default column type, like ColType.String.
The number of lines to skip before reading the header and data. Default: 0.
Useful for files with metadata, or comments at the beginning, or to give a custom header.
The maximum number of lines to read from the data. Default: null.
If null, all lines will be read.
Optional parsing options for columns initially read as String. Default: null.
Can configure locale, date format, double parsing, skipping types, etc.
If parserOptions or any of the arguments are null, the global parser configuration (org.jetbrains.kotlinx.dataframe.DataFrame.Companion.parser) will be queried.
The only exceptions are:
nullStrings, which, ifnull, will take the global setting +["", "NA", "N/A", "null", "NULL", "None", "none", "NIL", "nil"].skipTypes, which will always addtypesDeephavenAlreadyParsesto the given types or the global setting.
Whether to skip intermediate empty lines. Default: false.
If false, empty lines will be interpreted as having empty values if allowMissingColumns.
Whether to allow rows with fewer columns than the header. Default: true.
If true, rows that are too short will be interpreted as empty values.
Whether to ignore rows with more columns than the header. Default: true.
If true, rows that are too long will have those columns dropped.
The quote character. Default: ".
Used when field- or line delimiters should be interpreted as literal text.
For example: 123,"hello, there",456, would correspond to: 123; hello, there; 456.
Whether to ignore leading and trailing blanks around non-quoted fields. Default: true.
Whether to ignore leading and trailing blanks inside quoted fields. Default: false.
Whether to parse the data in parallel. Default: true.
If true, the data will be read and parsed in parallel by the Deephaven parser. This is usually faster but can be turned off for debugging.
Read CSV Url to DataFrame
Reads any CSV url to a DataFrame.
Note that if input dataframe contains duplicate column names, they will be automatically renamed in the resulting DataFrame.
Parameters you can use to customize the reading process include, for instance, delimiter, header, colTypes, readLines, and parserOptions. See the param list below for all settings.
The integration is built upon Deephaven CSV.
Similar Functions
With the overloads of DataFrame.readCsv(), you can read any CSV by File, Path, URL, or InputStream. Reading by file path or URL can also be done by passing a String.
For example, DataFrame.readCsv("input.csv") or with some options:
file = File("input.csv"),
parserOptions = ParserOptions(locale = Locale.US),
colTypes = mapOf("a" toColType.Int, ColType.DEFAULTtoColType.String),
readLines = 1000L,
)
ZIP (.zip) or GZIP (.gz) files are supported by default. compression is automatically detected.
You can also read "raw" CSV data from a String like this:
DataFrame.readCsvStr("a,b,c", delimiter = ",")
Parameters
The URL from which to fetch the data. Use charset to specify the encoding. Can also be compressed as .gz or .zip, see Compression.
The field delimiter character. Default: ','.
Ignored if hasFixedWidthColumns is true.
The compression of the data. Default: Compression.None, unless detected otherwise from the input file or url.
The character set the input is encoded in. Default: null
If null, the Charset will be read from the BOM of the provided input, defaulting to UTF-8 if no BOM is found.
Whether the data has fixed-width columns instead of a single delimiter. Default: false.
Fixed-width columns can occur, for instance, in multi-space delimited data, where the columns are separated by multiple spaces instead of a single delimiter, so columns are visually aligned. Column widths are determined by the header in the data (if present), or manually by setting fixedColumnWidths.
The fixed column widths. Default: empty list.
Requires hasFixedWidthColumns. If empty, the column widths will be determined by the header in the data (if present), else, this manually sets the column widths. The number of widths should match the number of columns.
The expected ColType per column name. Default: empty map, a.k.a. infer every column type.
If supplied for a certain column name (inferred from data or given by header), the parser will parse the column with the specified name as the specified type, else it will infer the type.
e.g. colTypes = mapOf("colName" toColType.Int). You can also set ColType.DEFAULTtoColType.X to set a default column type, like ColType.String.
The number of lines to skip before reading the header and data. Default: 0.
Useful for files with metadata, or comments at the beginning, or to give a custom header.
The maximum number of lines to read from the data. Default: null.
If null, all lines will be read.
Optional parsing options for columns initially read as String. Default: null.
Can configure locale, date format, double parsing, skipping types, etc.
If parserOptions or any of the arguments are null, the global parser configuration (org.jetbrains.kotlinx.dataframe.DataFrame.Companion.parser) will be queried.
The only exceptions are:
nullStrings, which, ifnull, will take the global setting +["", "NA", "N/A", "null", "NULL", "None", "none", "NIL", "nil"].skipTypes, which will always addtypesDeephavenAlreadyParsesto the given types or the global setting.
Whether to skip intermediate empty lines. Default: false.
If false, empty lines will be interpreted as having empty values if allowMissingColumns.
Whether to allow rows with fewer columns than the header. Default: true.
If true, rows that are too short will be interpreted as empty values.
Whether to ignore rows with more columns than the header. Default: true.
If true, rows that are too long will have those columns dropped.
The quote character. Default: ".
Used when field- or line delimiters should be interpreted as literal text.
For example: 123,"hello, there",456, would correspond to: 123; hello, there; 456.
Whether to ignore leading and trailing blanks around non-quoted fields. Default: true.
Whether to ignore leading and trailing blanks inside quoted fields. Default: false.
Whether to parse the data in parallel. Default: true.
If true, the data will be read and parsed in parallel by the Deephaven parser. This is usually faster but can be turned off for debugging.
Read CSV File or URL to DataFrame
Reads any CSV file or url to a DataFrame.
Note that if input dataframe contains duplicate column names, they will be automatically renamed in the resulting DataFrame.
Parameters you can use to customize the reading process include, for instance, delimiter, header, colTypes, readLines, and parserOptions. See the param list below for all settings.
The integration is built upon Deephaven CSV.
Similar Functions
With the overloads of DataFrame.readCsv(), you can read any CSV by File, Path, URL, or InputStream. Reading by file path or URL can also be done by passing a String.
For example, DataFrame.readCsv("input.csv") or with some options:
file = File("input.csv"),
parserOptions = ParserOptions(locale = Locale.US),
colTypes = mapOf("a" toColType.Int, ColType.DEFAULTtoColType.String),
readLines = 1000L,
)
ZIP (.zip) or GZIP (.gz) files are supported by default. compression is automatically detected.
You can also read "raw" CSV data from a String like this:
DataFrame.readCsvStr("a,b,c", delimiter = ",")
Parameters
The file path or URL to read the data from. Use charset to specify the encoding. Can also be compressed as .gz or .zip, see Compression.
The field delimiter character. Default: ','.
Ignored if hasFixedWidthColumns is true.
The compression of the data. Default: Compression.None, unless detected otherwise from the input file or url.
The character set the input is encoded in. Default: null
If null, the Charset will be read from the BOM of the provided input, defaulting to UTF-8 if no BOM is found.
Whether the data has fixed-width columns instead of a single delimiter. Default: false.
Fixed-width columns can occur, for instance, in multi-space delimited data, where the columns are separated by multiple spaces instead of a single delimiter, so columns are visually aligned. Column widths are determined by the header in the data (if present), or manually by setting fixedColumnWidths.
The fixed column widths. Default: empty list.
Requires hasFixedWidthColumns. If empty, the column widths will be determined by the header in the data (if present), else, this manually sets the column widths. The number of widths should match the number of columns.
The expected ColType per column name. Default: empty map, a.k.a. infer every column type.
If supplied for a certain column name (inferred from data or given by header), the parser will parse the column with the specified name as the specified type, else it will infer the type.
e.g. colTypes = mapOf("colName" toColType.Int). You can also set ColType.DEFAULTtoColType.X to set a default column type, like ColType.String.
The number of lines to skip before reading the header and data. Default: 0.
Useful for files with metadata, or comments at the beginning, or to give a custom header.
The maximum number of lines to read from the data. Default: null.
If null, all lines will be read.
Optional parsing options for columns initially read as String. Default: null.
Can configure locale, date format, double parsing, skipping types, etc.
If parserOptions or any of the arguments are null, the global parser configuration (org.jetbrains.kotlinx.dataframe.DataFrame.Companion.parser) will be queried.
The only exceptions are:
nullStrings, which, ifnull, will take the global setting +["", "NA", "N/A", "null", "NULL", "None", "none", "NIL", "nil"].skipTypes, which will always addtypesDeephavenAlreadyParsesto the given types or the global setting.
Whether to skip intermediate empty lines. Default: false.
If false, empty lines will be interpreted as having empty values if allowMissingColumns.
Whether to allow rows with fewer columns than the header. Default: true.
If true, rows that are too short will be interpreted as empty values.
Whether to ignore rows with more columns than the header. Default: true.
If true, rows that are too long will have those columns dropped.
The quote character. Default: ".
Used when field- or line delimiters should be interpreted as literal text.
For example: 123,"hello, there",456, would correspond to: 123; hello, there; 456.
Whether to ignore leading and trailing blanks around non-quoted fields. Default: true.
Whether to ignore leading and trailing blanks inside quoted fields. Default: false.
Whether to parse the data in parallel. Default: true.
If true, the data will be read and parsed in parallel by the Deephaven parser. This is usually faster but can be turned off for debugging.
Read CSV InputStream to DataFrame
Reads any CSV input stream to a DataFrame.
Note that if input dataframe contains duplicate column names, they will be automatically renamed in the resulting DataFrame.
Parameters you can use to customize the reading process include, for instance, delimiter, header, colTypes, readLines, and parserOptions. See the param list below for all settings.
The integration is built upon Deephaven CSV.
Similar Functions
With the overloads of DataFrame.readCsv(), you can read any CSV by File, Path, URL, or InputStream. Reading by file path or URL can also be done by passing a String.
For example, DataFrame.readCsv("input.csv") or with some options:
file = File("input.csv"),
parserOptions = ParserOptions(locale = Locale.US),
colTypes = mapOf("a" toColType.Int, ColType.DEFAULTtoColType.String),
readLines = 1000L,
)
ZIP (.zip) or GZIP (.gz) files are supported by default. compression is automatically detected.
You can also read "raw" CSV data from a String like this:
DataFrame.readCsvStr("a,b,c", delimiter = ",")
Parameters
Represents the file to read. Use charset to specify the encoding.
The field delimiter character. Default: ','.
Ignored if hasFixedWidthColumns is true.
The compression of the data. Default: Compression.None, unless detected otherwise from the input file or url.
The character set the input is encoded in. Default: null
If null, the Charset will be read from the BOM of the provided input, defaulting to UTF-8 if no BOM is found.
Whether the data has fixed-width columns instead of a single delimiter. Default: false.
Fixed-width columns can occur, for instance, in multi-space delimited data, where the columns are separated by multiple spaces instead of a single delimiter, so columns are visually aligned. Column widths are determined by the header in the data (if present), or manually by setting fixedColumnWidths.
The fixed column widths. Default: empty list.
Requires hasFixedWidthColumns. If empty, the column widths will be determined by the header in the data (if present), else, this manually sets the column widths. The number of widths should match the number of columns.
The expected ColType per column name. Default: empty map, a.k.a. infer every column type.
If supplied for a certain column name (inferred from data or given by header), the parser will parse the column with the specified name as the specified type, else it will infer the type.
e.g. colTypes = mapOf("colName" toColType.Int). You can also set ColType.DEFAULTtoColType.X to set a default column type, like ColType.String.
The number of lines to skip before reading the header and data. Default: 0.
Useful for files with metadata, or comments at the beginning, or to give a custom header.
The maximum number of lines to read from the data. Default: null.
If null, all lines will be read.
Optional parsing options for columns initially read as String. Default: null.
Can configure locale, date format, double parsing, skipping types, etc.
If parserOptions or any of the arguments are null, the global parser configuration (org.jetbrains.kotlinx.dataframe.DataFrame.Companion.parser) will be queried.
The only exceptions are:
nullStrings, which, ifnull, will take the global setting +["", "NA", "N/A", "null", "NULL", "None", "none", "NIL", "nil"].skipTypes, which will always addtypesDeephavenAlreadyParsesto the given types or the global setting.
Whether to skip intermediate empty lines. Default: false.
If false, empty lines will be interpreted as having empty values if allowMissingColumns.
Whether to allow rows with fewer columns than the header. Default: true.
If true, rows that are too short will be interpreted as empty values.
Whether to ignore rows with more columns than the header. Default: true.
If true, rows that are too long will have those columns dropped.
The quote character. Default: ".
Used when field- or line delimiters should be interpreted as literal text.
For example: 123,"hello, there",456, would correspond to: 123; hello, there; 456.
Whether to ignore leading and trailing blanks around non-quoted fields. Default: true.
Whether to ignore leading and trailing blanks inside quoted fields. Default: false.
Whether to parse the data in parallel. Default: true.
If true, the data will be read and parsed in parallel by the Deephaven parser. This is usually faster but can be turned off for debugging.
Optional extra CsvSpecs configuration. Default: { it }.
Before instantiating the CsvSpecs, the CsvSpecs.Builder will be passed to this lambda. This will allow you to configure/overwrite any CSV / TSV parsing options.