Feb-05-2018, 09:48 PM
Hi,
I'm trying to split a line to use some numbers somwhere else, but i dont understand what is causing this error. I'm still a newbie in python so probably it's easy.
So the error shows that:
0.0 59.8 8.78 9.375 3546.53
0.0 59.77 8.77 9.375 3586.64
0.0 59.75 8.77 9.375 3627.19
and the code i use to organize the text:
Cordially,Samu3l
I'm trying to split a line to use some numbers somwhere else, but i dont understand what is causing this error. I'm still a newbie in python so probably it's easy.
So the error shows that:
Error:Traceback (most recent call last):
File "C:\Users\samue\Documents\Documents\prepa\PT\tipe\expérimentation\releves\moyenne_val_triée.py", line 18, in <module>
t,h,Text,Tint,lux = ligne.strip().split("\t")
ValueError: not enough values to unpack (expected 5, got 1)
The code i usewith open("data.txt","r") as f: for i in f: for _ in range(10): ligne=f.readline() print(ligne) t,h,Text,Tint,lux = ligne.strip().split("\t")Maybe it could help to see whhat look like the line i try to split:
0.0 59.8 8.78 9.375 3546.53
0.0 59.77 8.77 9.375 3586.64
0.0 59.75 8.77 9.375 3627.19
and the code i use to organize the text:
fichier=open("data.txt","w") for t,h,Text,Tint,Lux in zip(liste_t,liste_h,liste_Text,liste_Tint,liste_Lux): print(t,h,Text,Tint,Lux,sep="\t") t=str(t) h=str(h) Text=str(Text) Tint=str(Tint) Lux=str(Lux) fichier.write(t+"\t") fichier.write(h+"\t") fichier.write(Text+"\t") fichier.write(Tint+"\t") fichier.write(Lux+"\t"+"\n") fichier.close()As you see, I just show you the part of the programm which create the "\t" if you want to see the rest just ask.Same if you need further information.
Cordially,Samu3l