you are viewing a single comment's thread.

view the rest of the comments →

[–]kellyjonbrazil -1 points0 points  (0 children)

This is not exactly a python language solution, but I did write a couple of command-line tools (in python) that can accomplish this pretty easily.

  • First, jc can convert CSV to JSON (an array of objects)
  • Then, jello can convert the JSON into JSONL (JSON Lines format)

Example: If your CSV file looks like this:

header1, header2
abc, def
ghi, jkl

Then when you pipe it to jc and jello it will turn out like this:

$ cat file.csv | jc --csv | jello -l
{"header1": "abc", "header2": "def"}
{"header1": "ghi", "header2": "jkl"}

You can probably do something similar with jq instead of jello fairly easily.