From: Silvio Rhatto Date: Thu, 28 Jan 2021 19:17:56 +0000 (-0300) Subject: Fix: handle KeyError X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=52a7112cbf03345a30c683a67b84ba1560ce9b32;p=csv-hasher.git Fix: handle KeyError --- 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)