I have a program that takes voltages vs. time which is put into a file, 'logfile.txt'. Later the logfile is used to make a plot in Pylab. The program works fine except that the very first line in the logfile needs to be deleted before plotting. I don't know why, but the first line contains the last voltage from the previous test, even though the logfile shows empty before the start of each new test. For example here is typical of first 4 lines in logfile:
1379812114.42 2.056
1379812129.0 2.130
1379812129.22 2.252
1379812129.45 2.266
If I could just keep that first line out of the logfile and therefore out of the Pylab plot I'd be happy. That 2.056 is from a previous test and shouldn't be there. Here are the pertinent lines in the program:
with open('logfile.txt', 'a') as f:
while True:
volts = adc.readADCDifferential01(4096, 8)
sys.stdout.flush()
if volts >=2.0:
print >> f, time(), '{:.1f}'.format(volts)
sleep(0.1)