Last active
August 29, 2015 14:11
-
-
Save whitmo/ee398d91a913e3b667a4 to your computer and use it in GitHub Desktop.
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
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