osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A limit to writing to a file from a loop?


My program reads from a text file (A), modifies the data, and writes to another file (B).
This works until I reach about 300 writes and no more lines are written to file (B).

I had to create a Counter and increment it to 250 when it gets reset.  

Upon reset, I close the file (B) being written and reopen it for append.  

Then it accepts the entire list of lines of data.

 

Bizarre?

 

            CycleCounter += 1

            if CycleCounter > 250:

              CycleCounter = 1

              DateReadings.close()

              DateReadings=open("Date-ReadingsAndDoses.txt", "a")                        

              DateReadings.write("{0:15} {1:>8} {2:>8} {3:>8} {4:<2} {5:>8} {6:>8} {7:>10}".format

                              (ThisTimeDate, ThisReading, ThisDose1, ThisSensor, ThisTrend,

                               ThisTS, ThisPercent, SensorNumberDay2) + "\n")