Created
May 17, 2017 21:53
-
-
Save mtholder/d20bd158e45b0e9d83842d878c8404f5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sys | |
| fn = sys.argv[1] | |
| ls_list = [] | |
| mapping = {} | |
| with open(fn, 'r') as inp: | |
| for n, line in enumerate(inp): | |
| ls = line.split('\t|\t') | |
| assert len(ls) == 5 | |
| assert ls[-1] == '\n' | |
| if n > 0: | |
| uid = ls[0] | |
| name = ls[2] | |
| assert uid not in mapping | |
| mapping[uid] = name | |
| ls_list.append(ls) | |
| out = sys.stdout | |
| for n, ls in enumerate(ls_list): | |
| if n > 0: | |
| ls[0] = mapping[ls[0]] | |
| if ls[1]: | |
| ls[1] =mapping[ls[1]] | |
| out.write('\t|\t'.join(ls)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment