User Tools

Site Tools


compare

Differences

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

Link to this comparison view

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