The above notification of a duplicate is false. I do not only want to append to a text file. I also want to delete the oldest parts of the text file so to only keep the latest data.
I have a text file that has some information similar to below.
14.614, 14.624, 14.512, 14.615, etc.
Another number is added every ten minutes. I want to have separate text files that hold the past 365 days, 180 days, 90 days, 60 days, 30 days, 14 days, 7 days and 2 days worth of numbers. The code to do each will be the same, just with different numbers. Here is what I tried, but it adds every new number to the front of the list, not the end.
ff = open('AvailableTickets.txt', 'r').read()
ff2 = ff
ff = ff.replace(',', '')
ff = ff.split()
ff = map(float, ff)
if len(ff) < 10:
ff3 = open('TestTickets.txt', 'r+')
ff3.write(str(ff2))
else:
ff3 = open('TestTickets.txt', 'r+')
for x in range(0, 10):
ff3.write(str(ff[len(ff)-x])+', ')