Skip to content

Instantly share code, notes, and snippets.

@drincruz
Last active April 18, 2016 18:11
Show Gist options
  • Save drincruz/17438331e0badffaa1781ada57657606 to your computer and use it in GitHub Desktop.
Save drincruz/17438331e0badffaa1781ada57657606 to your computer and use it in GitHub Desktop.
Python JSON to CSV via Pandas
{"col0":{"0":0,"1":1,"2":2,"3":3,"4":4},"col1":{"0":4,"1":3,"2":2,"3":1,"4":0},"col2":{"0":5,"1":6,"2":7,"3":8,"4":9}}
"""
Quick example of converting json to csv with pandas
"""
import pandas as pd
import sys
with open(sys.argv[1], 'r') as json_file:
df = pd.read_json(json_file)
df.to_csv('/tmp/tmp.csv', index=False)
print('All done!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment