|
4 | 4 |
|
5 | 5 | # If you get a read-only filesystem error, add "storage.remount('/', False)" in boot.py |
6 | 6 | # Make sure you add a way to reverse this in boot.py or your CP device won't show up via USB |
7 | | -# See example below: |
| 7 | +# See example below: |
8 | 8 | # https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/data-logger |
9 | 9 |
|
10 | 10 | import os |
11 | 11 | import random |
12 | 12 | import circuitpython_csv as csv |
13 | 13 |
|
14 | 14 | # Check if .CSV file is already present. If not, we write CSV headers. |
15 | | -all_files = os.listdir() ## List all files in directory |
16 | | -if "datelog.csv" not in all_files: |
| 15 | +all_files = os.listdir() ## List all files in directory |
| 16 | +if "datelog.csv" not in all_files: |
17 | 17 | with open("datelog.csv", mode="w", encoding="utf-8") as writablefile: |
18 | 18 | csvwriter = csv.writer(writablefile) |
19 | 19 | csvwriter.writerow(["Year", "Month", "Day", "Hour", "Minute"]) |
20 | 20 |
|
21 | | -# Now that the file exists (or already did) we make a random date |
22 | | -year = random.randint(1999,2022); month = random.randint(1,12) |
23 | | -day = random.randint(1,30); hour = random.randint(0,23); minute = random.randint(0,60) |
| 21 | +# Now that the file exists (or already did) we make a random date |
| 22 | +year = random.randint(1999, 2022) |
| 23 | +month = random.randint(1, 12) |
| 24 | +day = random.randint(1, 30) |
| 25 | +hour = random.randint(0, 23) |
| 26 | +minute = random.randint(0, 60) |
24 | 27 |
|
25 | 28 | # We append this to the .CSV file |
26 | 29 | with open("datelog.csv", mode="a", encoding="utf-8") as writablefile: |
|
0 commit comments