From 6033ae9051653f431a69f5ca5127189f2fbf8ac5 Mon Sep 17 00:00:00 2001 From: rasbt Date: Mon, 10 Feb 2014 17:39:43 -0500 Subject: [PATCH] file diff script --- README.md | 0 closures.py | 0 cpu_time.py | 0 diff_files.py | 21 +++++++++++++++++++++ get_filename.py | 0 pickle_module.py | 0 read_file.py | 0 7 files changed, 21 insertions(+) mode change 100644 => 100755 README.md mode change 100644 => 100755 closures.py mode change 100644 => 100755 cpu_time.py create mode 100644 diff_files.py mode change 100644 => 100755 get_filename.py mode change 100644 => 100755 pickle_module.py mode change 100644 => 100755 read_file.py diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/closures.py b/closures.py old mode 100644 new mode 100755 diff --git a/cpu_time.py b/cpu_time.py old mode 100644 new mode 100755 diff --git a/diff_files.py b/diff_files.py new file mode 100644 index 0000000..5e36a7c --- /dev/null +++ b/diff_files.py @@ -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)) diff --git a/get_filename.py b/get_filename.py old mode 100644 new mode 100755 diff --git a/pickle_module.py b/pickle_module.py old mode 100644 new mode 100755 diff --git a/read_file.py b/read_file.py old mode 100644 new mode 100755