Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    Thanks @Homer . I will try it and will update about the result. just out of curiosity is it possible to get the data in below format also or it can be done only after converting csv? csv1--> 101,11111,a 101,11111,b 101,11111,c 101,11111,d 101,11111,e:abc csv2--> 102,22222,a csv3--> 103,33333,a 103,33333,b 103,33333,c csv4--> 104,44444,a 104,44444,b Commented Mar 21, 2019 at 7:06
  • To remove unnecessary quotes from @csv, one could pass the output through csvformat from the csvkit toolbox. That way, quotes that are needed will be kept. Commented Mar 21, 2019 at 7:58
  • @Homer, I am getting below error during this "jq -r '[.content[].information|[.c1, .c2, .c3|split(",")|.[]]] | (([range([.[] | length] | max)|"c" + (.+1|tostring)]|join(",")), (.[] | join(",")))' < sample.json" . Error : "split input and separator must be strings" Commented Mar 21, 2019 at 14:04
  • It sounds like your real data doesn't match the sample data and some of the values are not strings. I've put an extra pair of parentheses in to handle the case where something other than c3 is a non-string, but if the data is heterogeneous to the point that any c3 is not a string you may need a different tack to massage the data first. Commented Mar 21, 2019 at 19:13