Created
July 1, 2018 11:36
-
-
Save sainathadapa/1144ced2595a1366a53800f179223285 to your computer and use it in GitHub Desktop.
Loading Amazon review data into PostgreSQL
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 | |
def parse(path): | |
g = open(path, 'r') | |
for l in g: | |
yield json.dumps(eval(l), allow_nan=False, ensure_ascii=True) | |
f = open("kcore_5_strict.json", 'w') | |
for l in parse("kcore_5.json"): | |
f.write(l + '\n') | |
f = open("metadata_strict.json", 'w') | |
for l in parse("metadata.json"): | |
f.write(l + '\n') |
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
create table meta_json (values text); | |
create table reviews_json (values text); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment