Last active
April 20, 2017 01:07
-
-
Save VariantXYZ/acc838b8ea5a250abf663d5e2612833b 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
#!/usr/bin/python | |
import csv | |
new_file = "./apc_chat_new_jp.csv" | |
old_file = "./apc_chat_old_jp.csv" | |
with open(new_file, 'r', encoding='utf-8', newline='') as n: | |
with open(old_file, 'r', encoding='utf-8', newline='') as o: | |
new = csv.reader(n, delimiter=',') | |
old = csv.reader(o, delimiter=',') | |
new_map = {} | |
old_map = {} | |
key_counter = {} | |
for i, line in enumerate(new): | |
key = line[0].split("#")[0] + "|" + line[1] | |
value = line[0].split("#")[1] | |
if key in new_map: | |
if key not in key_counter: | |
key_counter[key] = 0 | |
else: | |
key_counter[key] = key_counter[key] + 1 | |
key = key + "#" + str(key_counter[key]) | |
else: | |
new_map[key] = value | |
key_counter = {} | |
for i,line in enumerate(old): | |
key = line[0].split("#")[0] + "|" + line[1] | |
value = line[0].split("#")[1] | |
if key in old_map: | |
if key not in key_counter: | |
key_counter[key] = 0 | |
else: | |
key_counter[key] = key_counter[key] + 1 | |
key = key + "#" + str(key_counter[key]) | |
else: | |
old_map[key] = value | |
for k, v in old_map.items(): | |
if k in new_map: | |
if new_map[k] != old_map[k]: | |
print("Old Key {0}#{1} changed to {0}#{2}".format(k.split("|")[0],old_map[k], new_map[k])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment