From dab9b02fcbeb2db6016c4ac7c1e38a84ef432080 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 6c659d9..0a71df6 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")