I'm trying to seperate a data file into lists depending on what day (or epoch) the data was taken. I'm trying to do it by telling the program that if the epoch of one point is the same as the previous point, add it to a list, and if not then to move on. I'm currently getting the error:
line 31,
if epoch[i] == epoch[i+1]:
TypeError: list indices must be integers, not float
This is what I currently have (I haven't written the bit telling it to move onto the next epoch yet).
epoch=[]
wavelength=[]
flux=[]
text_file = open("datafile.dat", "r")
lines1 = text_file.read()
#print lines1
text_file.close()
a = [float(x) for x in lines1.split()]
a1=0
a2=1
a3=2
while a1<len(a):
epoch.append(float(a[a1]))
wavelength.append(float(a[a2]))
flux.append(float(a[a3]))
a1+=3
a2+=3
a3+=3
#print epoch
x=[]
y=[]
z=[]
i = epoch[0]
if epoch[i] == epoch[i+1]:
x.append(epoch[i])
y.append(wavelength[i])
z.append(flux[i])
i+=1
#print x
#print z
I can't work out what I need to change! Thanks in advance.