]> apps.delaporte.us Git - dotfiles.git/commitdiff
Quick CSV entry script
authorEdward Delaporte <edward@delaporte.us>
Sun, 28 Jun 2026 04:05:06 +0000 (23:05 -0500)
committerEdward Delaporte <edward@delaporte.us>
Sun, 28 Jun 2026 19:15:07 +0000 (14:15 -0500)
bin/clerk

index 0fa3bb402f91e61c777efce80ca3254d8327ebd3..e4f7a19738f258f5160cfdef8e6b5e9a20062990 100755 (executable)
--- a/bin/clerk
+++ b/bin/clerk
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 
+import csv
 import os
 
 DATA_DIR=os.path.expanduser('~/Journal/2026/data')
@@ -18,3 +19,24 @@ 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
+    example = next(reader)
+
+print(example)
+    
+values = {}
+for key in fields:
+    print(key)
+    values[key] = input()
+
+print(values)
+if input() == 'y':
+    with open(file, 'a') as f:
+        writer = csv.DictWriter(f, fields)
+        writer.writerow(values)
+        print(f"Updated {file}")
+
+