diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2021-01-28 16:17:56 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2021-01-28 16:17:56 -0300 |
commit | 52a7112cbf03345a30c683a67b84ba1560ce9b32 (patch) | |
tree | e7bb62bff55ce07494612951c073650a1d00e47e | |
parent | fc5d9ba9e251db721a525974e6a8a7acde58814a (diff) | |
download | csv-hasher-52a7112cbf03345a30c683a67b84ba1560ce9b32.tar.gz csv-hasher-52a7112cbf03345a30c683a67b84ba1560ce9b32.tar.bz2 |
Fix: handle KeyError
-rwxr-xr-x | csv-hasher.py | 6 |
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) |