Created
July 24, 2017 15:53
-
-
Save uralbash/8a459a21633146ae8acc7b88eca0f169 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
from collections import defaultdict | |
def tree(): return defaultdict(tree) | |
groups = tree() | |
with open('taxonomy.en-US.txt') as file: | |
for row in file.readlines(): | |
items = row.split(' > ') | |
print(items) | |
foo = groups | |
for item in items: | |
foo = foo[item] | |
import pprint | |
out_file = open('out.txt', 'w') | |
pprint.pprint(groups, out_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment