[Tutor] Compare two text files

Dave Angel davea at davea.name
Mon Oct 13 11:30:53 CEST 2014


Crusier <crusier at gmail.com> Wrote in message:

>  
 Attached are the two text files (stocklist.txt & stocklist1.txt) which I want to do a comparison with the content of the file, Basically, I want to see if there are any new numbers added to the file. 

>  Please comment on the sequence of the file:
1. First, Open up the File No. 1 and put the string into a list. 
2. Second, Open the File No. 2 and put the string into a list. 
3. Use difflib to compare

I don't see what the included code had to do with the problem, 
 since difflib doesn’t care about numbers. It compares sequences
 (like lists) of strings.

So you have a couple of files to read in. Normally you might use
 readlines, but there don't seem to be any newlines in the files.
 So you'll need split, or something similar. 

Come back when you've made an attempt at the problem, and ask a
 question about your code. Otherwise you're just asking others to
 do your homework for you. That's no way to learn.

And please post in plain text. Html messages can cause lots of
 problems. 




-- 
DaveA



More information about the Tutor mailing list