I can't seem to figure out how to use jq to turn my data into a csv. I have the following json:
{
"id": 2,
"type": "message",
"date": "2010-01-11T01:19:45",
"edited": "1969-12-31T19:00:00",
"from": "USER1",
"from_id": 5514,
"text": "Message1"
},
{
"id": 3,
"type": "message",
"date": "2010-01-11T01:19:28",
"edited": "1969-12-31T19:00:00",
"from": "USER2",
"from_id": 5515,
"text": "Message2"
},
{
"id": 4,
"type": "message",
"date": "2010-01-11T01:19:28",
"edited": "1969-12-31T19:00:00",
"from": "USER1",
"from_id": 5514,
"text": "Message3"
},
I'm trying to get the date, from, and text from the json and to output it in a csv that looks like:
From,Date,Text
USER1,2010-01-11T01:19:45,Message1
USER2,2010-01-11T01:19:28,Message2
USER1,2010-01-11T01:19:28,Message3
Is there a way to do this with jq or would something different be better to use?