Skip to content

Instantly share code, notes, and snippets.

@uralbash
Created July 24, 2017 15:53
Show Gist options
  • Save uralbash/8a459a21633146ae8acc7b88eca0f169 to your computer and use it in GitHub Desktop.
Save uralbash/8a459a21633146ae8acc7b88eca0f169 to your computer and use it in GitHub Desktop.
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