Trying to convert a CSV file into a JSON
Here is two sample lines :
-21.3214077;55.4851413;Ruizia cordata
-21.3213078;55.4849803;Cossinia pinnata
Because the jq
solution does not handle CSV escaping, column names at the first line, commented-out lines and other common CSV "features", I have extended the CSV Cruncher tool to allow reading CSV and writing it as JSON. It's not exactly "Bash", but neither is jq
:)
It's primarily a CSV-as-SQL processing app, so it's not completely trivial, but here is the trick:
./crunch -in myfile.csv -out output.csv --json -sql 'SELECT * FROM myfile'
It also allows output as JSON object per line or proper JSON array. See the documentation.
It's in beta quality, so all feedback or pull requests are welcome.