PapaParse icon indicating copy to clipboard operation
PapaParse copied to clipboard

Delimiter option in `unparse` doesn't support multi-character delimiters

Open pkrumins opened this issue 8 years ago • 2 comments

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"

pkrumins avatar Oct 03 '17 05:10 pkrumins

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?

pokoli avatar Oct 04 '17 07:10 pokoli

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:

  1. Convert your file to string.
  2. Search for a single char that is not included in the file string.
  3. Replace the delimiter in the file string with the new char.
  4. parse / unpause the file string.

code4break avatar Jun 30 '23 09:06 code4break