]> apps.delaporte.us Git - dotfiles.git/blobdiff - bin/clerk
Add kdevelop recipe
[dotfiles.git] / bin / clerk
index 0fa3bb402f91e61c777efce80ca3254d8327ebd3..39f764cbc2e10854a53f2160b6c86c3633ed8471 100755 (executable)
--- a/bin/clerk
+++ b/bin/clerk
@@ -1,11 +1,12 @@
 #!/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)
@@ -18,3 +19,38 @@ choice = input()
 file = data_files[choice]
 
 print(file)
+
+with open(file, 'r') as f:
+    reader = csv.reader(f, delimiter=',', quotechar='"')
+    fields = next(reader)  # require header row
+    first_example = next(reader)
+    for line in reader:
+        last_example = next(reader)
+
+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:
+    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)
+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}")
+
+