This repository is deprecated; please follow the main search page or use the ‘Related code repos’ widget on the right side of the current page.

jsontoexcel

Converts a json file to csv and excel format. It recursively explores the json file and flattens its data to output so it can be viewed as excel/csv.

Takes a json file as input and converts it to csv and xlsx files. It recursively explores the json file's data (nodes).
It creates labels which correspond to the keys of the items parsed.
It concatenates the full path tree json of each object to the label's name structure and flattens the output in 2 dimensions so that the data can be converted to csv / xlsx format.
You can use the -v flag for verbose output.

Installation

Prerequisites:

  • Python 3
  • the xlsxwriter Python library

You can install the library using pip:

  • pip install XlsxWriter

Usage

Script call definition:

python JsonToExcel.py <Path to json> <Path and output files names(optional)>

The first argument you specify will be the input json file. The second is the base name used for the creation of the excel and csv file. If the second argument is not specified, the json file's name will be used.

This will output two files named: myfile.csv myfile.xlsx

  • python JsonToExcel.py myfile.json

Whereas this will output two files named: output.csv output.xlsx

  • python JsonToExcel.py myfile.json output

You can place the -v argument anywhere. e.g.:

  • python JsonToExcel.py myfile.json -v output
  • python JsonToExcel.py -v myfile.json output
  • python JsonToExcel.py myfile.json -v

Known Issues

There are no issues so far. Please communicate with me if you run into any, so that I can improve the script.

Getting Help

If you face any issues, please create an issue in the GitHub built-in issue tracker.

Contributing

Please contact me if you want to contribute to this project and I will give you further instructions.

View code on GitHub
  • Owner

  • Contributors

    +2Github contributors
  • Categories

  • Programming Languages

    Python
  • License

    MIT License

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.