FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 1dc1aff0 authored by Dr T. Mona's avatar Dr T. Mona
Browse files

feat: converting double nested Race and Genotype information in to string.

(Adding missing columns)
parent ad69c7e2
No related branches found
No related tags found
No related merge requests found
......@@ -101,6 +101,7 @@ def nested_to_flattened(df):
RAW_COLUMNS = [
"ObservationID",
"OriginalID",
"PublishedLevel",
"Origin",
"Country",
"Latitude",
......@@ -108,6 +109,7 @@ def nested_to_flattened(df):
"FieldArea",
"Cultivar",
"CollectionDate",
"UpdateDate",
"GrowthStage",
"listDisease"]
for i in RAW_COLUMNS:
......@@ -177,14 +179,16 @@ def nested_to_flattened(df):
row[nested_row[rr]['DiseaseName'] + '.Incident'] = nested_row[rr]['IncidenceCategory']
row[nested_row[rr]['DiseaseName'] + '.Severity'] = nested_row[rr]['SeverityCategory']
race_list = []
geno_list = []
nested_row[rr]['listResult'] = [{'Race': 'Alma', 'Genotype': 'Korte'},{'Race': 'Banan', 'Genotype': 'Malna'}] # !!!!!!!!! DELETE THIS LINE !!!!!!!!!!
for i in range(len(nested_row[rr]['listResult'])):
race_list.append(nested_row[rr]['listResult'][i]['Race'])
geno_list.append(nested_row[rr]['listResult'][i]['Genotype'])
# TODO: check if the separation symbol is in the string or not
row[nested_row[rr]['DiseaseName'] + '.Race'] += nested_row[rr]['listResult'][i]['Race']
row[nested_row[rr]['DiseaseName'] + '.Genotype'] += nested_row[rr]['listResult'][i]['Genotype']
if i != len(nested_row[rr]['listResult'])-1:
row[nested_row[rr]['DiseaseName'] + '.Race'] += '+'
row[nested_row[rr]['DiseaseName'] + '.Genotype'] += '+'
row[nested_row[rr]['DiseaseName'] + '.Race'] = race_list
row[nested_row[rr]['DiseaseName'] + '.Genotype'] = geno_list
df.loc[index] = row
return df
......@@ -206,13 +210,15 @@ def get_WRT_form_as_csv(form_credentials: dict, jobPath: str, config: dict, stat
column_parser_dict = {
"ObservationID" : 'KEY',
"OriginalID" : 'None',
"Origin" : "Origin",
"PublishedLevel" : 'PublishedLevel',
"Origin" : 'Origin',
"Country" : ('parse_cases',(('name_out','surveyor_infromation-country'),('cases', COUNTRY_ABBREVIATIONS_DICT))),
"Latitude" : 'survey_infromation-location-Latitude',
"Longitude" : 'survey_infromation-location-Longitude',
"FieldArea" : 'site_information-field_area',
"Cultivar" : 'site_information-variety',
"CollectionDate" : ('parse_date',(('name_out','survey_infromation-survey_date'),('fmt_in','%m/%d/%Y'))),
"UpdateDate" : 'None',
"GrowthStage" : 'site_information-growth_stage',
"listDisease" : 'None',
"YR.Severity" : ('parse_cases',(('name_out','yellow_rust-yellowrust_severity'),('cases', cases_severity),('dtype', int))),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment