From f5aca0d4cdfe4d2bbdcd56581b0da5cd6979de46 Mon Sep 17 00:00:00 2001 From: Ponrar Date: Sun, 9 Jul 2023 03:14:12 -0700 Subject: [PATCH] Add simple process script --- process | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 process diff --git a/process b/process new file mode 100755 index 0000000..c3008dd --- /dev/null +++ b/process @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +import sys +import csv + +# Strip whitespace left and right of a string +def strip(s: str): + return s.rstrip().lstrip() + +def main(): + filepaths = sys.argv[1:] + print(f'{filepaths=}') + + delim=',' + quotechar='"' + + for file in filepaths: + with open(file, newline='') as csvfile: + reader = csv.reader(csvfile, delimiter=delim, quotechar=quotechar, skipinitialspace=True) + next(reader) # Skip the first row + for row in reader: + stripped = map(strip, row) + [keyword, text, sound] = stripped + print(keyword, text, sound) +main()