Last active
April 18, 2016 18:11
-
-
Save drincruz/17438331e0badffaa1781ada57657606 to your computer and use it in GitHub Desktop.
Python JSON to CSV via Pandas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"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}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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