From 64719365eb8cc02b038e0efe51be5d6f18d2af04 Mon Sep 17 00:00:00 2001 From: tm689 <tm689@cam.ac.uk> Date: Wed, 30 Aug 2023 09:33:51 +0100 Subject: [PATCH] feat: convert severity string values to int --- coordinator/ProcessorSurveysnewODK.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/coordinator/ProcessorSurveysnewODK.py b/coordinator/ProcessorSurveysnewODK.py index b42947b..dafd033 100644 --- a/coordinator/ProcessorSurveysnewODK.py +++ b/coordinator/ProcessorSurveysnewODK.py @@ -33,6 +33,21 @@ cases_incident = { 'high':'high' } +cases_severity = { + '1':1, + '5':5, + '10':10, + '15':15, + '20':20, + '30':30, + '40':40, + '50':50, + '60':60, + '70':70, + '80':80, + '80+':80, + } + def get_from_kobotoolbox(url,form_id,form_token,**kwargs): '''Make the HTTP request, then checking the status code.''' @@ -109,7 +124,7 @@ def get_newODK_form_as_csv(form_credentials: dict, jobPath: str, config: dict, s 'imei' : 'imei', 'leaf_rust/leafrust_host_plant_reaction' : 'leaf_rust-leafrust_host_plant_reaction', 'leaf_rust/leafrust_incidence' : ('parse_cases',(('name_out','leaf_rust-leafrust_incidence'),('cases', cases_incident))), - 'leaf_rust/leafrust_severity' : 'leaf_rust-leafrust_severity', + 'leaf_rust/leafrust_severity' : ('parse_cases',(('name_out','leaf_rust-leafrust_severity'),('cases', cases_severity),('dtype', int))), 'live_leafrust_samples' : 'SET-OF-live_leafrust_samples', 'live_leafrust_samples_count' : 'live_leafrust_samples_count', 'live_stemrust_samples' : 'SET-OF-live_stemrust_samples', @@ -127,7 +142,7 @@ def get_newODK_form_as_csv(form_credentials: dict, jobPath: str, config: dict, s 'site_information/survey_site' : 'site_information-survey_site', 'site_information/variety' : 'site_information-variety', 'start' : ('parse_date',(('name_out','start'),('fmt_in','%Y-%m-%dT%H:%M:%S.%f%z'))), - 'stem_rust/Stemrust_severity' : 'stem_rust-Stemrust_severity', + 'stem_rust/Stemrust_severity' : ('parse_cases',(('name_out','stem_rust-Stemrust_severity'),('cases', cases_severity),('dtype', int))), 'stem_rust/stemrust_host_plant_reaction' : 'stem_rust-stemrust_host_plant_reaction', 'stem_rust/stemrust_incidence' : ('parse_cases',(('name_out','stem_rust-stemrust_incidence'),('cases', cases_incident))), 'survey_infromation/location' : ('parse_location_kobotoolbox',()), @@ -139,8 +154,8 @@ def get_newODK_form_as_csv(form_credentials: dict, jobPath: str, config: dict, s 'today' : ('parse_date',(('name_out','today'),('fmt_in','%Y-%m-%d'))), 'username' : 'username', 'yellow_rust/yellowrust_host_plant_reaction' : 'yellow_rust-yellowrust_host_plant_reaction', - 'yellow_rust/yellowrust_incidence' : ('parse_cases',(('name_out','leaf_rust-leafrust_incidence'),('cases', cases_incident))), - 'yellow_rust/yellowrust_severity' : 'yellow_rust-yellowrust_severity', + 'yellow_rust/yellowrust_incidence' : ('parse_cases',(('name_out','yellow_rust-yellowrust_incidence'),('cases', cases_incident))), + 'yellow_rust/yellowrust_severity' : ('parse_cases',(('name_out','yellow_rust-yellowrust_severity'),('cases', cases_severity),('dtype', int))), } logger.debug('Performing download') -- GitLab