Last active
May 20, 2021 18:01
-
-
Save janeadams/718aa001f18637c75db803c600ea2fdc to your computer and use it in GitHub Desktop.
Sample JSON Parse from UI Download, for StoryWrangler
This file contains 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
import json | |
import pandas as pd | |
import csv | |
dfs={} | |
with open('storywrangler_data.json') as json_file: | |
data = json.load(json_file) | |
for ngram in data['metadata']['ngrams']: | |
dfs[ngram] = pd.DataFrame(data['data'][ngram], columns=['date',data['metadata']['metric']]) | |
for ngram in dfs: | |
dfs[ngram].to_csv(f"{ngram}-{data['metadata']['language']}-{data['metadata']['metric']}.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment