Skip to content

Instantly share code, notes, and snippets.

@whitmo
Last active August 29, 2015 14:11
Show Gist options
  • Save whitmo/ee398d91a913e3b667a4 to your computer and use it in GitHub Desktop.
Save whitmo/ee398d91a913e3b667a4 to your computer and use it in GitHub Desktop.
import json
from path import path
source = path('/home/whit/proj/workloadz/17c09d289f6e7c1f01f7/old.json')
data = json.loads(source.text())
from operator import itemgetter
pt = data['db'][0]['data']['posts_tags']
ti = itemgetter('tag_id')
pi = itemgetter('post_id')
pi_to_tags = {}
[pi_to_tags.setdefault(pid, []).append(tid) for pid, tid in ((pi(x), ti(x)) for x in pt)]
print pi_to_tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment