File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 88after_file = Path ('./data/ALA_after.csv' )
99outfile = Path ('./data/ALA_diff.csv' )
1010
11+ # Create a set object by mapping the "before" file onto a tuple object
12+ # (an immutable list), passing teh result of `open()` to `csv.reader()`
1113before = set (
1214 map (
1315 tuple ,
1416 csv .reader (open (before_file ))
1517 )
1618)
1719
20+ # Repeat for the second ("after") file
1821after = set (map (tuple , csv .reader (open (after_file ))))
1922
23+ # Use the caret (^) operator to get the symmetric difference between the sets
24+ # https://www.linuxtopia.org/online_books/programming_books/python_programming/python_ch16s03.html
25+
2026differences = before ^ after
2127
2228output = csv .writer (open (outfile , mode = 'w' ))
2329
2430compared = sorted (differences , key = lambda x : x [0 ], reverse = True )
2531
26- for iter , row in enumerate ():
32+ for count , row in enumerate ():
2733 output .writerow (row )
2834
29- print (f"Wrote { iter } rows to output file." )
35+ print (f"Wrote { count } rows to output file." )
You can’t perform that action at this time.
0 commit comments