aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2021-01-28 16:17:56 -0300
committerSilvio Rhatto <rhatto@riseup.net>2021-01-28 16:17:56 -0300
commit52a7112cbf03345a30c683a67b84ba1560ce9b32 (patch)
treee7bb62bff55ce07494612951c073650a1d00e47e
parentfc5d9ba9e251db721a525974e6a8a7acde58814a (diff)
downloadcsv-hasher-52a7112cbf03345a30c683a67b84ba1560ce9b32.tar.gz
csv-hasher-52a7112cbf03345a30c683a67b84ba1560ce9b32.tar.bz2
Fix: handle KeyError
-rwxr-xr-xcsv-hasher.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/csv-hasher.py b/csv-hasher.py
index e3f71e5..fe206f8 100755
--- a/csv-hasher.py
+++ b/csv-hasher.py
@@ -106,7 +106,11 @@ class CsvHasher:
df.columns = sample.columns
# Hashing the column
- df[self.args.colname[0]] = self.apply_hash(df)
+ try:
+ df[self.args.colname[0]] = self.apply_hash(df)
+ except KeyError as e:
+ print('Column not found: ' + self.args.colname[0])
+ exit (1)
# Writing the new CSV output
df.to_csv(self.args.outfile[0], index=False, mode='a', header=write_header)