Interface CsvParseOptions

Hierarchy

  • CsvParseOptions

Index

Properties

Optional bom

bom: boolean

If true, detect and exclude the byte order mark (BOM) from the CSV input if present.

Optional cast

cast: boolean | CastingFunction

If true, the parser will attempt to convert input string to native types. If a function, receive the value as first argument, a context as second argument and return a new value. More information about the context properties is available below.

Optional cast_date

cast_date: boolean | CastingDateFunction

If true, the parser will attempt to convert input string to dates. If a function, receive the value as argument and return a new value. It requires the "auto_parse" option. Be careful, it relies on Date.parse.

Optional columns

columns: ColumnOption[] | boolean | ((record: any) => ColumnOption[])

List of fields as an array, a user defined callback accepting the first line and returning the column names or true if autodiscovered in the first CSV line, default to true, affect the result data set in the sense that records will be objects instead of arrays.

Optional comment

comment: string

Treat all the characters after this one as a comment, default to '' (disabled).

Optional delimiter

delimiter: string | Buffer

Set the field delimiter. One character only, defaults to comma.

Optional escape

escape: string | Buffer

Set the escape character, one character only, defaults to double quotes.

Optional from

from: number

Start handling records from the requested number of records.

Optional from_line

from_line: number

Start handling records from the requested line number.

Optional info

info: boolean

Generate two properties info and record where info is a snapshot of the info object at the time the record was created and record is the parsed array or object.

Optional ltrim

ltrim: boolean

If true, ignore whitespace immediately following the delimiter (i.e. left-trim all fields), defaults to false. Does not remove whitespace in a quoted field.

Optional max_record_size

max_record_size: number

Maximum numer of characters to be contained in the field and line buffers before an exception is raised, used to guard against a wrong delimiter or record_delimiter, default to 128000 characters.

Optional objname

objname: string

Name of header-record title to name objects by.

Optional quote

quote: string | boolean | Buffer | null

Optional character surrounding a field, one character only, defaults to double quotes.

Optional raw

raw: boolean

Generate two properties raw and row where raw is the original CSV row content and row is the parsed array or object.

Optional record_delimiter

record_delimiter: string | string[] | Buffer | Buffer[]

One or multiple characters used to delimit record rows; defaults to auto discovery if not provided. Supported auto discovery method are Linux ("\n"), Apple ("\r") and Windows ("\r\n") row delimiters.

Optional relax

relax: boolean

Preserve quotes inside unquoted field.

Optional relax_column_count

relax_column_count: boolean

Discard inconsistent columns count, default to false.

Optional relax_column_count_less

relax_column_count_less: boolean

Discard inconsistent columns count when the record contains less fields than expected, default to false.

Optional relax_column_count_more

relax_column_count_more: boolean

Discard inconsistent columns count when the record contains more fields than expected, default to false.

Optional rtrim

rtrim: boolean

If true, ignore whitespace immediately preceding the delimiter (i.e. right-trim all fields), defaults to false. Does not remove whitespace in a quoted field.

Optional skip_empty_lines

skip_empty_lines: boolean

Dont generate empty values for empty lines. Defaults to false

Optional skip_lines_with_empty_values

skip_lines_with_empty_values: boolean

Don't generate records for lines containing empty column values (column matching /\s*/), defaults to false.

Optional skip_lines_with_error

skip_lines_with_error: boolean

Skip a line with error found inside and directly go process the next line.

Optional to

to: number

Stop handling records after the requested number of records.

Optional to_line

to_line: number

Stop handling records after the requested line number.

Optional trim

trim: boolean

If true, ignore whitespace immediately around the delimiter, defaults to false. Does not remove whitespace in a quoted field.

Generated using TypeDoc