

jq or jsoncsv that you have tried) instead of writing your own parser.Ĭonvert to json by simply adding after the last row and a comma to every except the last row. "Outdated","Watt","Timestamp","A_Plus","A_Plus_HT","A_Plus_NT","A_Minus"įor me it seems easier and safer to first convert to proper json, then use a parser (e.g. You now have an array-of-arrays, with a header array at the top, that may be mapped back to an array of CSV (and finally to individual CSV rows): $ jq -r -slurp 'to_entries |


perform a reduction of the array of rows, initializing it with the keys extracted from the 0 th element.slurp the whole file into an indexed array of rows.If you do care about headers, it's more complicated. The structure resembles a JSON file, but unfortunately the structure does not quite match. I would like to convert a text file into CSV format.
