Skip to content

A simple CLI tool that converts a JSON file to CSV format.

License

Notifications You must be signed in to change notification settings

0xpetersatoshi/json2csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json2csv

This is a simple CLI tool that converts a JSON file to CSV format.

Installation

  • Clone the repo
  • cd into project folder
  • run pip install .

Basic Usage

Simple

json2csv -i myfile.json

JSON file has nested datastructures

json2csv -i myfile.json --flatten

This will recursively run through a JSON file and try and flatten nested datastructures.

Needed data is nested within JSON structure

Example:

{
  "results" : [
    {"key": "value"},
    {"key2": "value"},
    {"key3": "value"},
  ]
}

If you just need to convert the data contained in the "results" key, you can pass that key to the --data-key argument and the tool will extract that data and convert it to CSV.

json2csv -i myfile.json --date-key results

Saving the output

By default, the CSV output file will be saved to the current directory from where the command is run. You can specify the output path and file name by using the -o argument.

json2csv -i myfile.json -o /tmp/mydata.csv

About

A simple CLI tool that converts a JSON file to CSV format.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages