PapaParse
PapaParse copied to clipboard
Delimiter option in `unparse` doesn't support multi-character delimiters
I was trying to convert JSON to CSV and used multiple characters as a delimiter but it didn't accept it. Here's a small example:
> Papa.unparse('[{"a": "1", "b": "2", "c": "3"}]', { delimiter: '()' })
"a,b,c
1,2,3"
Per definition, a delimiter is compased by only one char.
I don't see any use case about having multiple delimiters. Could you specify one?
This problem also exists for the parsing method. If I use a delimiter that is longer than 1 char, then only every x-th row is parsed, where x is equal to the length of the delimiter.
As a workaround I did the following:
- Convert your file to string.
- Search for a single char that is not included in the file string.
- Replace the delimiter in the file string with the new char.
- parse / unpause the file string.