CSV to JSON is too fragile
See original GitHub issueThe CSV to JSON script is too fragile and breaks on real-world data such as double-quoted columns to contain commas and double-double-quotes for literal double-quotes.
I had a \r in some of my data which means the script isn’t standardizing to \n line endings.
Test:

Result:

Expected:

The JSON to CSV gets similarly confused in that it uses \"
for literal double-quotes instead of the CSV convention of double-double-quotes within a quoted column.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Deal with CSV containing nested JSON objects (comma hell!)
Alas, my regex kung-fu is too weak to create something flexible enough based on the arbitrary nature of the JSON objects that may...
Read more >How to convert a CSV file to JSON in 1 minute / CSV to JSON
A free, quick, and easy utility to upload your CSV file and convert to a JSON formatted text.
Read more >Other ways to convert CSV to JSON (more performance)
Hello everybody,. I am using an Azure Logic app to convert a CSV file to JSON to transform the data into a SharePoint...
Read more >Catch exception for transform.Unmarshal csv - support - HUGO
If you must use CSV, you could try to parse it yourself, but that will be very fragile. For example: {{ $map :=...
Read more >Team Builder - PvPoke
Build your team for Pokemon GO Trainer Battles. See how your Pokemon match up offensively and defensively, discover which Pokemon are the best...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For what it’s worth: I grabbed the minified version of Papa Parse and pasted it straight into my
csv_to_json.js
, and it did work. I did have to take out therequire
and fix the code to beIf the pattern Boop wants to follow is to have all dependencies in the lib folder, then creating a new file in there for Papa (with its LICENSE, of course) is probably the cleanest way, but before I throw up a PR I wanted to double-check that this is the approach you want.
Sorry for the double-post, but I just realized that there’s a combination of an assumption and a “Limitation” at play around the “header” stuff in this script.
First, we’re assuming that this data has a header (both in the original and in my fix). There’s a “Limitation” (and I use that term VERY loosely because I actually see this as a feature/simplicity) in Boop that you can’t pass parameters to the scripts.
So… the solutions I see are:
CSV to JSON (headers)
, the otherCSV to JSON (headerless)
state.text
could be settings for a script 🤮If we went with # 1, I’d argue that the 2nd script would just be an optional script, and the default would be
headers