By using
result = open("data/"+ name + "_" + timestamp + ".csv", "w")
result.write("time; data1; data2; data3 \n")`
I open a file and fill it with the column identifiers.
Using
while True:
timestamp = time.strftime("%H:%M:%S", time.localtime())
data1,data2,data3 = device.fetchData()
result.write(timestamp +";"+ str(data1) +";"+ str(data1) +";"+ str(data3) +"\n")
time.sleep(seconds)
the .csv-file should be filled with measuring data. The problem now is, that if I check the file after exiting the script, it's completely empty, not even the column identifiers are present. However, if I use a for-loop, it works like it should.
Very strange for my understanding.
result.close()forloop so it's hard to guess. Also it's unclear whatfetchDatadoes. Try to create a minimal example that shows the issue, without dependencies to other parts of your project.