From 52a7112cbf03345a30c683a67b84ba1560ce9b32 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 28 Jan 2021 16:17:56 -0300 Subject: Fix: handle KeyError --- csv-hasher.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3