Skip to content

Instantly share code, notes, and snippets.

@Back2Basics
Forked from cluelesscoder/gist:5777013
Last active December 18, 2015 11:39
Show Gist options
  • Save Back2Basics/5777442 to your computer and use it in GitHub Desktop.
Save Back2Basics/5777442 to your computer and use it in GitHub Desktop.
import string
with open('somefile.txt', 'r') as infile:
fread = infile.readlines()
d = {}
for x in fread:
if "\xe2\x80\xa2 " in x:
x = x.strip()
val = x.split("\xe2\x80\xa2 ")
d[value].append(val[1])
else:
val = x.strip()
d[val] = []
value = val
print d
@cluelesscoder
Copy link

Thanks for your help! I ended up using a bunch of list comprehensions to get it where I wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment