skip to Main Content

jq convert jsonlines to csv with header without slurp

a potentially huge json-lines file with objects of known structure is to be converted to csv with headers. example {"name":"name_0","value_a":"value_a_0","value_b":"val_b_0"} {"name":"name_1","value_a":"value_a_1","value_b":"val_b_1"} {"name":"name_2","value_a":"value_a_2","value_b":"val_b_2"} {"name":"name_3","value_a":"value_a_3","value_b":"val_b_3"} {"name":"name_4","value_a":"value_a_4","value_b":"val_b_4"} expected output "name","value_a","value_b" "name_0","value_a_0","val_b_0" "name_1","value_a_1","val_b_1" "name_2","value_a_2","val_b_2" "name_3","value_a_3","val_b_3" "name_4","value_a_4","val_b_4" currently tried (if (input_line_number == 1 ) then…

VIEW QUESTION

Update a json file using csv file contents

I've 2 files: changes.csv and sample.json. My csv file is like following: header "a", "b" "a11","b1" "a22","b2" "a33","b3" and the json file is like: [ {"a":"a1","b":"b1"}, {"a":"a2","b":"b2"}, {"a":"a3","b":"b3"}, {"a":"a4","b":"b4"} ] I need to write a jq command, which make changes…

VIEW QUESTION

Convert CSV with nested JSON object to JSON

I have a sample CSV message: header1,header2,header3 value1,value2,{"name":"John","age":30,"car":null} How to convert it in form of embedded JSON as in: { "header1": "value1", "header2": "value2", "header3": "{"name":"John","age":30,"car":null}" } I am using Jackson schema builder with default column separator: CsvSchema.builder().disableQuoteChar().setUseHeader(true).build(); CsvMapper.builder().enable(CsvParser.Feature.IGNORE_TRAILING_UNMAPPABLE, CsvParser.Feature.WRAP_AS_ARRAY).build();

VIEW QUESTION

JSON to CSV (python)

i have a JSON file as follow: { "temperature": [ { "ts": 1672753924545, "value": "100" } ], "temperature c1": [ { "ts": 1672753924545, "value": "30.99036523512186" } ], "conductivite_c1": [ { "ts": 1672753924545, "value": "18.195760116755046" } ], "pression_c1": [ { "ts":…

VIEW QUESTION

having trouble converting csv to json using bash jq

I have one stream output stored in csv file, I need help converting csv to json: my csv looks like: cat output.csv "k","a1",1,"b1","c1","d1",1 "l","a2",2,"b2","c2","d2",2 "m","a3",3,"b3","c3","d3",3 "n","a4",4,"b4","c4","d4",4 "o","a5",5,"b5","c5","d5",5 Required output: note: I need key configuration to be added to json. {…

VIEW QUESTION
Back To Top
Search