All of the following options can be passed to any of the formatting methods.
delimiter#Type: string
Default: ','
Specify an alternate field delimiter such as ;
or \t
. Example
When specifying an alternate delimiter
you may only pass in a single character delimiter
Type: string
Default: '\n'
Specify an alternate row delimiter (i.e \r\n
). Example
Type: string|boolean
Default: '"'
If provided as a string it will be used to quote fields that contain a delimiter. Example
If set to true
the default quote will be used.
This is the same as not providing the option
If set to false
then quoting will be disabled
If your field could contain a delimiter then you may end up with extra columns
escape#Type: string
Default: '"'
The character to use when escaping a value that is quoted
and contains a quote
character that is not the end of the field. Example
i.e
: First,"Name"' => '"First,""Name"""
Type: boolean
Default: false
Set to true
to include a row delimiter at the end of the csv.
Type: boolean
Default: false
Set to true
if you want the first character written to the stream to be a utf-8 BOM character.
Type: null|boolean|string[]
Default: null
If true
then the headers will be auto detected from the first row. Example
headers
will be the first row processed[ ['header', 'column'], ['header2', 'column2'] ]
) then the first element in each array will be used.If there is not a headers row and you want to provide one then set to a string[]
. Example
Type: boolean
Default: true
Set to false you dont want to write headers.
infoThis option can be used to append to an existing csv.
noteType: boolean
Default: false
Set to true if you always want headers written, even if no rows are written.
cautionThis will throw an error if headers are not specified as an array.
quoteColumns#Type: boolean|boolean[]|{[string]: boolean}
Default: false
If true
then columns and headers will be quoted (unless quoteHeaders
is specified).
If it is an object then each key that has a true value will be quoted ((unless quoteHeaders
is specified). Example
If it is an array then each item in the array that is true will have the column at the corresponding index quoted (unless quoteHeaders
is specified). Example
If quoteHeaders
is not specified this option will apply to both columns and headers.
Type: boolean|boolean[]|{[string]: boolean}
Default: the quoteColumns
value
If true
then all headers will be quoted.
If it is an object then each key that has a true value will be quoted (see example below)
If it is an array then each item in the array that is true will have the header at the corresponding index quoted
transform#Type: (row) => Row | (row, cb) => void
Default: null
A function that accepts a row and returns a transformed one to be written, or your function can accept an optional callback to do async transformations.
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