Re: File Compare with difflib.context_diff

2009-03-20 Thread JanC
JohnV wrote: > I have a txt file that gets appended with data over a time event. The > data comes from an RFID reader and is dumped to the file by the RFID > software. I want to poll that file several times over the time period > of the event to capture the current data in the RFID reader. > > W

Re: File Compare with difflib.context_diff

2009-03-19 Thread JohnV
Here is the latest version of the code: currentdata_file = r"C:\Users\Owner\Desktop\newdata.txt" # the latest download from the clock lastdata_file = r"C:\Users\Owner\Desktop\mydata.txt" # the prior download from the clock output_file = r"C:\Users\Owner\Desktop\out.txt" # will hold delta clock dat

Re: File Compare with difflib.context_diff

2009-03-18 Thread JohnV
The below code does the trick with one small problem left to be solved import shutil import string currentdata_file = r"C:\Users\Owner\Desktop\newdata.txt" # the current download from the clock lastdata_file = r"C:\Users\Owner\Desktop\mydata.txt" # the prior download from the clock output_file =

Re: File Compare with difflib.context_diff

2009-03-18 Thread Gabriel Genellina
En Wed, 18 Mar 2009 21:02:42 -0200, Emile van Sebille escribió: JohnV wrote: > What I want to do is compare the old data (lets day it is saved to a file called 'lastdata.txt') with the new data (lets day it is saved to a file called 'currentdata.txt') and save the new appended data to a va

Re: File Compare with difflib.context_diff

2009-03-18 Thread Emile van Sebille
JohnV wrote: > What I want to do is compare the old data (lets day it is saved to a file called 'lastdata.txt') with the new data (lets day it is saved to a file called 'currentdata.txt') and save the new appended data to a variable You may get away with something like: (untested) newdata=op

Re: File Compare with difflib.context_diff

2009-03-18 Thread JohnV
Maybe something like this will work though I am not sure of my quotes and what to import import shutil f = open(r'C:\Users\Owner\Desktop\mydata.txt', 'r') read_data1 = f.read() f.close() shutil.copy('C:\Users\Owner\Desktop\newdata.txt', 'C:\Users\Owner \Desktop\out.txt') file = open(r'C:\Users\O

Re: File Compare with difflib.context_diff

2009-03-18 Thread Chris Rebert
On Wed, Mar 18, 2009 at 2:30 PM, JohnV wrote: > I have a txt file that gets appended with data over a time event.  The > data comes from an RFID reader and is dumped to the file by the RFID > software.  I want to poll that file several times over the time period > of the event to capture the curre

Re: File compare

2005-10-14 Thread PyPK
but what if case 1: no.of keys in f1 > f2 and case2: no.of keys in f1 < f2. Should'nt we get 1.1 if case 1 and 0.9 if case 2?? it errors of with a keyerror.? -- http://mail.python.org/mailman/listinfo/python-list

Re: File compare

2005-10-14 Thread Magnus Lycka
PyPK wrote: > I have two files > file1 in format > > 'AA' 1 T T > 'AB' 1 T F > > file2 same as file1 > > 'AA' 1 T T > 'AB' 1 T T > > Also the compare should be based on id. So it should look for line > starting with id 'AA' (for example) and then match the line so if in > second case. S

Re: File compare

2005-10-12 Thread PyPK
Not for homework. But anyway thanks much... -- http://mail.python.org/mailman/listinfo/python-list

Re: File compare

2005-10-12 Thread Larry Bates
Sounds a little like "homework", but I'll help you out. There are lots of ways, but this works. import sys class fobject: def __init__(self, inputfilename): try: fp=open(inputfilename, 'r') self.lines=fp.readlines() except IOError: print "Una

Re: File compare

2005-10-12 Thread PyPK
Note that the code i wrote wont do the compare based on id which i am looking for..it just does a direct file to file compare.. -- http://mail.python.org/mailman/listinfo/python-list