All of the following options can be passed to any of the parse methods.
objectMode#Type: boolean
Default: true
Ensure that all rows are emitted as objects.
If set to false
all data will be a JSON version of the row.
Type: string
Default: ','
The delimiter that will separate columns.
Set this option if your file uses an alternate delimiter such as ;
or \t
. Example
When specifying an alternate delimiter you may only pass in a single character!
quote#Type: string|null
Default: '"'
The character to use to quote fields that contain a delimiter.
(e.g. "first,name",last name
=> ['first,name', 'last name']
)
If you set to null
then all quoting will be ignored.
Type: string
Default: '"'
The character to used tp escape quotes inside of a quoted field.
i.e: First,"Name"' => '"First,""Name"""
Type: boolean|string[]|(string[]) => string[])
Default: false
If set to true
the first row will be treated as the headers. Example
If you want to manually specify the headers set to a string[]
. Example
If you wish to discard the first row and use your own headers you need to set the renameHeaders option to true
If you wish to transform the headers you can provide a transform function. Example
If your rows are arrays, and you wan to skip certain columns you can provide a sparse array. Example
noteWhen setting the headers option to a function it will always rename the headers
cautionIf you specify headers and there are more columns than headers the following rules will apply
strictColumnHandling
set to true
a data-invalid
event will be emitted and parsing will continue.strictColumnHandling
is not specified an error
will be emitted and parsing will stop.discardUnmappedColumns
to true
the extra columns will be dropped.If headers either parsed, provided or transformed are NOT unique, then an error will be emitted and the stream will stop parsing.
renameHeaders#Type: boolean
Default: false
If you want the first line of the file to be removed and replaced by the one provided in the headers
option. Example
This option should only be used if the headers
option is a string[]
If the headers
option is a function then this option is always set to true.
Type: boolean
Default: false
Set to true
to ignore empty rows. Example
this will discard columns that are all white space or delimiters.
comment#Type: string|null
Default: null
If your CSV contains comments you can use this option to ignore lines that begin with the specified character (e.g. #
).
Type: boolean
Default: false
If you want to discard columns that do not map to a header.
noteThis is only valid in the case when the number of parsed columns is greater than the number of headers.
strictColumnHandling#Type: boolean
Default: false
If you want to consider empty lines/lines with too few fields as invalid and emit a data-invalid
event
This option is only considered when headers
are present.
Type: boolean
Default: false
Set to true
to trim all white space from columns.
Type: boolean
Default: false
Set to true
to right trim all columns.
Type: boolean
Default: false
Set to true
to left trim all columns.
Type: string
Default: 'utf8'
Passed to StringDecoder when decoding incoming buffers. Change if incoming content is not 'utf8' encoded.
maxRows#Type: number
Default: 0
If number is > 0
then only the specified number of rows will be parsed.(e.g. 100
would return the first 100 rows of data). Example
Type: number
Default: 0
If number is > 0
then the specified number of parsed rows will be skipped. Example
Type: number
Default: 0
If number is > 0
the specified number of lines will be skipped. Example
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4