Description
Summary
The library should be able to parse CSVs while considering multiple different potential quote character used for each value independently. E.g. allow a CSV mixing both single quote and double quotes.
Motivation
Use cases where CSVs mix values ported over from other formats (e.g. literals in a programming language) which enclose values in single quotes, and manually input. Reconciling the two quote styles would enable parsing the CSV regardless of which (if any) quote character was used.
Alternative
Regex to strip replace single quotes with double quotes via a utility, though this will break quotes in values.
Draft
Let the quote
option take in an array of characters, and consider each when parsing the values.
Example unit test:
const records = parse(`
a,"b",'c'
'd',e,"f"
`.trim(), {
quote: ['"', '\''],
});
assert.deepStrictEqual(
records, [
['a', 'b', 'c'],
['d', 'e', 'f']
]
);
Additional context
Similar to #400. Perhaps automated detection is a sensible option.