Created
September 13, 2017 17:58
-
-
Save ODiogoSilva/d0af91ea22c00420b261b2b29059c7f3 to your computer and use it in GitHub Desktop.
duplicates removal on the fly
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
from collections import defaultdict | |
your_dict = {} | |
lookup_table = defaultdict(list) | |
for line in file_handle: | |
acc, fields = get_fields(line) | |
for i in fields: | |
# Dunno if this happens at all | |
if acc in lookup_table[i]: | |
lookup_table[i].append(acc) | |
your_dict[acc] = [x for x in fields if x not in lookup_table[acc]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment