Writing to a local file is giving an error
Posted: Fri Oct 12, 2018 4:42 pm
Hello,
I am trying to write to a local file every 100ms, and after the program has run I expect to see a txt file with numbers 0 through 99 in it. However, the text in the file stops at 5, and I cannot debug this. (The program given below is the minimum program that illustrates the issue, and my overall objective is to store data from 6 ADC inputs every millisecond for about a week on an SDCard. I am deliberately opening and closing the file at over iteration of the loop).
Hardware: Pyboard 1.1, using with OSX.
Thanks for the help!
MAIN.PY
# main.py -- put your code here!
import pyb
c = 0
while c< 100:
pyb.delay(100)
f = open('data.txt', 'a')
f.write(str(c)+'\n')
f.flush()
f.close()
c = c+1
I am trying to write to a local file every 100ms, and after the program has run I expect to see a txt file with numbers 0 through 99 in it. However, the text in the file stops at 5, and I cannot debug this. (The program given below is the minimum program that illustrates the issue, and my overall objective is to store data from 6 ADC inputs every millisecond for about a week on an SDCard. I am deliberately opening and closing the file at over iteration of the loop).
Hardware: Pyboard 1.1, using with OSX.
Thanks for the help!
MAIN.PY
# main.py -- put your code here!
import pyb
c = 0
while c< 100:
pyb.delay(100)
f = open('data.txt', 'a')
f.write(str(c)+'\n')
f.flush()
f.close()
c = c+1