#!/usr/bin/python
import csv
+from datetime import datetime as dt
import os
-DATA_DIR=os.path.expanduser('~/Journal/2026/data')
+DATA_DIR=os.path.expanduser('~/Journal/2026/Data')
data_files = {}
-os.path.expanduser('~/Journal/2026/data')
for root, _, files in os.walk(DATA_DIR):
for file in files:
name, ext = os.path.splitext(file)
with open(file, 'r') as f:
reader = csv.reader(f, delimiter=',', quotechar='"')
fields = next(reader) # require header row
- example = next(reader)
+ first_example = next(reader)
+ for line in reader:
+ last_example = next(reader)
-print(example)
+print(first_example)
+print("...")
+print(last_example)
+
+DATE_FORMAT = '%Y-%m-%d'
+
+def today():
+ return dt.now().strftime(DATE_FORMAT)
+
values = {}
for key in fields:
- print(key)
- values[key] = input()
+ default = ''
+ if key == 'date':
+ default = today()
+ values[key] = input(f"{key} [{default}]\n").strip() or default
+print("Break with Ctrl+C if incorrect:")
print(values)
-if input() == 'y':
- with open(file, 'a') as f:
- writer = csv.DictWriter(f, fields)
- writer.writerow(values)
- print(f"Updated {file}")
+input() # Assume break with Ctrl+C if incorrect
+
+with open(file, 'a') as f:
+ writer = csv.DictWriter(f, fields)
+ writer.writerow(values)
+ print(f"Updated {file}")