I want to make a code to read files that contain data from a sensor. I got stuck at the start:
import numpy as np
a = []
b = []
x = []
y = []
for line in open("YAZID.txt", "r"):
lines = [i for i in line.split()]
print(lines)
a.append(float(lines[0]))
b.append(float(lines[1]))
for i in a:
i = float(i)
x.append(i)
print(x)
it gives me this error
['0,375', '7,84E-02']
Traceback (most recent call last):
File "c:\Users\pc orange\Desktop\graphs\graph.py", line 32, in <module>
a.append(float(lines[0]))
ValueError: could not convert string to float: '0,375'
they get stuck at being strings
is there a way to make them into float so that i can make a plot with them the numbers are really little and i need to read the whole number each time
a.append(float(lines[0].replace(',','.'))