User Tools

Site Tools


compare

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
compare [2018/05/06 20:08]
zeppo created
compare [2018/05/06 20:14] (current)
zeppo
Line 1: Line 1:
- f = open("​C:​\\temp\old.csv",​ "​r"​) +To compare two files and update the orginal 
- lines = f.read() +   
- ​f.close()  +    ​f = open("​C:​\\temp\old.csv",​ "​r"​) 
- +    lines = f.read() 
- f2 = open("​C:​\\temp\\new.csv",​ "​r"​) +    f.close()  
- cnt = 0 +    f2 = open("​C:​\\temp\\new.csv",​ "​r"​) 
- for var in f2.readlines():​ +    cnt = 0 
-    f = open("​C:​\\temp\old.csv",​ "​a"​) +    for var in f2.readlines():​ 
-    if var not in lines: +       ​f = open("​C:​\\temp\old.csv",​ "​a"​) 
-        cnt = cnt +1 +       ​if var not in lines: 
-        print(var) +         ​cnt = cnt +1 
-        f.write(var) +         ​print(var) 
-         +         ​f.write(var) 
-         +    f.close() ​              
-  +    f2.close() 
- f.close() ​              +    print(cnt, ​ " ​  new transactions"​)
- ​f2.close() +
- +
- print(cnt, ​ " ​  new transactions"​)+
compare.1525655319.txt.gz · Last modified: 2018/05/06 20:08 by zeppo