From 918e026f554978a099230d68d24f24f16a3b0285 Mon Sep 17 00:00:00 2001 From: Sakimori Date: Mon, 1 Sep 2025 13:53:16 -0400 Subject: [PATCH] added error catching for no cands --- csv_merge.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/csv_merge.py b/csv_merge.py index 46d67b6..fa7cc4c 100644 --- a/csv_merge.py +++ b/csv_merge.py @@ -13,9 +13,12 @@ def process(directory): dirname = os.path.basename(subdir) if dirname == '': dirname = os.path.basename(os.path.dirname(subdir)) - mainCSV = pd.read_csv(os.path.join(subdir, f"{dirname}.csv")) - candCSV = pd.read_csv(os.path.join(subdir, "cands","results_a.csv")) - merge(mainCSV, candCSV, os.path.join(subdir, f"{dirname}_merged.csv")) + try: + mainCSV = pd.read_csv(os.path.join(subdir, f"{dirname}.csv")) + candCSV = pd.read_csv(os.path.join(subdir, "cands","results_a.csv")) + merge(mainCSV, candCSV, os.path.join(subdir, f"{dirname}_merged.csv")) + except FileNotFoundError: + logger.error(f"{dirname} has no candidates!") def merge(mainDF:pd.DataFrame, candDF:pd.DataFrame, outname): #add new columns to main dataframe