From ecb71d07a96a7f922d4397846592e9a1c9cf9683 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 11 Dec 2024 10:50:01 +0000 Subject: [PATCH] allow only importing national data if a column doesn't matches a value Some sheets have data for, e.g. multiple years in and we only want one of them so update the skip logic to allow for skipping unless the column matches versus skipping if the column does not match --- .../management/commands/import_national_data.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crowdsourcer/management/commands/import_national_data.py b/crowdsourcer/management/commands/import_national_data.py index f359ff8..e7bbc4a 100644 --- a/crowdsourcer/management/commands/import_national_data.py +++ b/crowdsourcer/management/commands/import_national_data.py @@ -190,7 +190,15 @@ def import_answers(self, user, rt, df, q, details): for _, row in df.iterrows(): if details.get("skip_check", None) is not None: skip_check = details["skip_check"] - if row[skip_check["col"]] == skip_check["val"]: + if ( + skip_check.get("unless_match") + and row[skip_check["col"]] != skip_check["val"] + ): + continue + elif ( + not skip_check.get("unless_match") + and row[skip_check["col"]] == skip_check["val"] + ): continue gss_col = details.get("gss_col", "Local Authority Code")