Skip to content

Commit 7cf6590

Browse files
committed
Reformatted disklogger example file
1 parent 2f0e572 commit 7cf6590

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

examples/csv_disklogger.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,26 @@
44

55
# If you get a read-only filesystem error, add "storage.remount('/', False)" in boot.py
66
# 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:
88
# https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/data-logger
99

1010
import os
1111
import random
1212
import circuitpython_csv as csv
1313

1414
# 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:
1717
with open("datelog.csv", mode="w", encoding="utf-8") as writablefile:
1818
csvwriter = csv.writer(writablefile)
1919
csvwriter.writerow(["Year", "Month", "Day", "Hour", "Minute"])
2020

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)
2427

2528
# We append this to the .CSV file
2629
with open("datelog.csv", mode="a", encoding="utf-8") as writablefile:

0 commit comments

Comments
 (0)