From: Edward Delaporte Date: Sun, 28 Jun 2026 04:05:06 +0000 (-0500) Subject: Quick CSV entry script X-Git-Url: https://us-delaporte.pagekite.me/gitweb/dotfiles.git/commitdiff_plain/e607671cc5f8992240864b233a4a9cc4353f2909?ds=inline Quick CSV entry script --- diff --git a/bin/clerk b/bin/clerk index 0fa3bb4..e4f7a19 100755 --- 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}") + +