Created
June 5, 2017 02:23
-
-
Save kylepjohnson/d41e7559bf0c710b092606652d3b3853 to your computer and use it in GitHub Desktop.
This file contains 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 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses file: https://gist.github.com/kylepjohnson/2eb8693e4948a255e2949d0258634670