how to store a json file in terminal into csv file

582 Views Asked by At

I have used the Twitter standard search API to search tweets and I used:

twurl /1.1/search/tweets.json?q=I%20have%20been%20diagnosed%20with%20depression

in the terminal.

The outcome is a json file. How can I store it in CSV file?

1

There are 1 best solutions below

0
On

If you just want to convert the json file you're getting as an output to a CSV file, you can use "json2csv"

You can use it as a module or directly from the command line, and it'll convert your json file into a csv file with column titles and the proper line endings.

To install globally:

$ npm install -g json2csv

To install as a project dependency:

$ npm install json2csv --save

You can find more information on using it at the npm website: https://www.npmjs.com/package/json2csv