Kod: Markera allt
import time
file = 'bme280.dat'
#file = 'd1.dat'
press = 3
timex = 0
f1 = open(file, 'r')
while True:
line = f1.readline()
if line == '': #test EOF
f1.close()
print('EOF')
exit()
#print(line)
line1 = line.split(',')
#print(line1)
print(type(line1[press]))
print( line1[timex],line1[press])
print( line1[timex],float(line1[press]))
time.sleep(2)
Kod: Markera allt
pi@mumin3:~/pigpio $ python3 read_d1_2.py
<class 'str'>
["Mon Apr 25 16:39:22 2022" "1010.58"
Traceback (most recent call last):
File "read_d1_2.py", line 18, in <module>
print( line1[timex],float(line1[press]))
ValueError: could not convert string to float: ' "1010.58"'
Kod: Markera allt
pi@mumin3:~/pigpio $ python3
Python 3.5.3 (default, Nov 18 2020, 21:09:16)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> s="1010.58"
>>> float(s)
1010.58
>>>
Kod: Markera allt
["Mon Apr 25 18:19:30 2022", "25.14", "20.28", "1010.59", "21.88"]
["Mon Apr 25 18:24:31 2022", "25.17", "20.67", "1010.50", "22.40"]
["Mon Apr 25 18:29:31 2022", "25.07", "20.84", "1010.50", "22.33"]
["Mon Apr 25 18:34:32 2022", "25.04", "21.06", "1010.52", "22.08"]