Skip to content

Instantly share code, notes, and snippets.

@sainathadapa
Created July 1, 2018 11:36
Show Gist options
  • Save sainathadapa/1144ced2595a1366a53800f179223285 to your computer and use it in GitHub Desktop.
Save sainathadapa/1144ced2595a1366a53800f179223285 to your computer and use it in GitHub Desktop.
Loading Amazon review data into PostgreSQL
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')
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