Skip to content

Instantly share code, notes, and snippets.

@kylepjohnson
Created June 5, 2017 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylepjohnson/d41e7559bf0c710b092606652d3b3853 to your computer and use it in GitHub Desktop.
Save kylepjohnson/d41e7559bf0c710b092606652d3b3853 to your computer and use it in GitHub Desktop.
import os
with open(os.path.expanduser('~/Downloads/subscript-non-pairs')) as fo:
text = fo.read()
pairs = text.split('\n\n')
map_sub_nosub = {}
for pair in pairs:
key, val = pair.split('\n')
new_key = key.split('#', maxsplit=1)[0]
try: # breaks when trying to parse end of file
new_key = eval(new_key)
except SyntaxError:
continue
if isinstance(new_key, tuple):
new_key = new_key[0]
new_val = val.split('#', maxsplit=1)[0]
try: # breaks when trying to parse end of file
new_val = eval(new_val)
except SyntaxError:
pass
if isinstance(new_val, tuple):
new_val = new_val[0]
iota = '\u0399'
iota = eval(repr(iota))
new_val += iota
map_sub_nosub[new_key] = new_val
@kylepjohnson
Copy link
Author

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