import json from sys import argv allsymbols = json.load(open('./unicode-latex.json')) symbols = ['≼', '→', '⊀', '⋠', '≺', '∀', '∈', '₂', '₁', 'ₐ', 'ₘ', 'ₙ', 'ᵢ' ] symbols = {s: allsymbols[s] for s in symbols} print(symbols) def read_by_char(fname): with open(fname, 'r') as fp: for line in fp.readlines(): for ch in line: yield ch def convert(ch): return symbols[ch] if ch in symbols else ch newfile = [convert(ch) for ch in read_by_char(argv[1])] with open(argv[2], 'w') as f: f.writelines(newfile)