Expand|Select|Wrap|Line Numbers
- # Open each file and suck all of the data into an array called searchlines
- # Then sort the array
- with open("folder1/telephone_histogram.txt", "r") as f:
- searchlines = f.readlines()
- with open("folder2/telephone_histogram.txt", "r") as f:
- searchlines = searchlines+f.readlines()
- searchlines.sort();
- # dupe will be the variable to compare against the value of the next line
- # dupe_count will be the number of times the item is found in the file
- # dupe is initialized to a junk value and dupe_count is set to 0
- dupe="DUPE"
- dupe_count=1
- for i, line in enumerate(searchlines):
- if dupe in line:
- dupe_count +=1;
- else:
- if dupe_count==1:
- #Item is unique
- print searchlines[i-1];
- nothing=False# delete this line. It is just here so I can comment out the lines before without error
- else:
- #Item is duplicated print the item preceeded by the number of times it was duplicated
- #print dupe_count, searchlines[i-1];
- nothing=False # delete this line. It is just here so I can comment out the lines before without error
- dupe_count=1;
- dupe=line;]