mirror of
https://github.com/rasbt/python_reference.git
synced 2025-01-18 15:27:09 +00:00
file diff script
This commit is contained in:
parent
01af8c0a81
commit
6033ae9051
0
closures.py
Normal file → Executable file
0
closures.py
Normal file → Executable file
0
cpu_time.py
Normal file → Executable file
0
cpu_time.py
Normal file → Executable file
21
diff_files.py
Normal file
21
diff_files.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Sebastian Raschka, 2014
|
||||
#
|
||||
# Print lines that are different between 2 files. Insensitive
|
||||
# to the order of the file contents.
|
||||
|
||||
id_set1 = set()
|
||||
id_set2 = set()
|
||||
|
||||
with open('id_file1.txt', 'r') as id_file:
|
||||
for line in id_file:
|
||||
id_set1.add(line)
|
||||
|
||||
with open('id_file2.txt', 'r') as id_file:
|
||||
for line in id_file:
|
||||
id_set2.add(line)
|
||||
|
||||
diffs = id_set2.difference(id_set1)
|
||||
|
||||
for d in diffs:
|
||||
print(d)
|
||||
print("Total differences:",len(diffs))
|
0
get_filename.py
Normal file → Executable file
0
get_filename.py
Normal file → Executable file
0
pickle_module.py
Normal file → Executable file
0
pickle_module.py
Normal file → Executable file
0
read_file.py
Normal file → Executable file
0
read_file.py
Normal file → Executable file
Loading…
Reference in New Issue
Block a user