Using the Miller command line tool I want to convert a CSV file with headers into a JSON array.
Currently I am using this command: mlr --icsv --ojson cat sample.csv > sample.json
It is outputting JSON, but not in array format.
This is the sample CSV input:
Keyword, Weight, Quantity
Apple, 10, 2345
Orange, 23, 467
Banana, 2345, 2345
And this is the output I am getting from Miller:
{ "Keyword": "Apple", "Weight": 10, "Quantity": 2345 }
{ "Keyword": "Orange", "Weight": 23, "Quantity": 467 }
{ "Keyword": "Banana", "Weight": 2345, "Quantity": 2345 }
As you can see this output is JSON Lines, not an array format.
I want the JSON to be an array, like this:
[
{ "Keyword": "Apple", "Weight": 10, "Quantity": 2345 },
{ "Keyword": "Orange", "Weight": 23, "Quantity": 467 },
{ "Keyword": "Banana", "Weight": 2345, "Quantity": 2345 }
]
What is the correct Miller command for that?