for year in years: year = str(year) entries = [] for row in table_entries: # fill out necessary fields from render_templates import get_level_from_score entry = { "country": {"name": row["name"], "name_de": row["name_de"], "id": row["id"]}, "score": row["score"]["year" + year], "undernourished": row["details"]["undernourished_" + year]["score"], "stunting": row["details"]["stunting_" + year]["score"], "wasting": row["details"]["wasting_" + year]["score"], "mortality": row["details"]["mortality_" + year.replace("2015", "2013")]["score"], } entry["DT_RowClass"] = get_level_from_score(entry["score"]) entry["undernourished"] += "*" if row["details"]["undernourished_" + year]["estimate"] else "" entry["stunting"] += "*" if row["details"]["stunting_" + year]["estimate"] else "" entry["wasting"] += "*" if row["details"]["wasting_" + year]["estimate"] else "" # fetch this country's zone for z in zones: if z['code'] == entry["country"]["id"]: entry['zone'] = z['zonecode'] break if not entry.get('zone'): print "No zone match: " + entry["country"]['name'] entry['zone'] = '' # add it to the entry list entries.append(entry) trends_data = {'data': entries}
for year in years: year = str(year) entries = [] for row in table_entries: # fill out necessary fields from render_templates import get_level_from_score entry = { "country": {"name": row["name"], "name_de": row["name_de"], "id": row["id"]}, "score": row["score"]["year" + year], "undernourished": row["details"]["undernourished_" + year]["score"], "stunting": row["details"]["stunting_" + year]["score"], "wasting": row["details"]["wasting_" + year]["score"], "mortality": row["details"]["mortality_" + year.replace("2016", "2015")]["score"], } entry["DT_RowClass"] = get_level_from_score(entry["score"],entry["country"]["id"]) entry["undernourished"] += "*" if row["details"]["undernourished_" + year]["estimate"] else "" entry["stunting"] += "*" if row["details"]["stunting_" + year]["estimate"] else "" entry["wasting"] += "*" if row["details"]["wasting_" + year]["estimate"] else "" # fetch this country's zone for z in zones: if z['code'] == entry["country"]["id"]: entry['zone'] = z['zonecode'] break if not entry.get('zone'): print "No zone match: " + entry["country"]['name'] entry['zone'] = '' # add it to the entry list entries.append(entry)
"id": row["id"] }, "score": row["score"]["year" + year], "undernourished": row["details"]["undernourished_" + year]["score"], "stunting": row["details"]["stunting_" + year]["score"], "wasting": row["details"]["wasting_" + year]["score"], "mortality": row["details"]["mortality_" + year.replace("2016", "2015")]["score"], } entry["DT_RowClass"] = get_level_from_score(entry["score"]) entry["undernourished"] += "*" if row["details"][ "undernourished_" + year]["estimate"] else "" entry["stunting"] += "*" if row["details"]["stunting_" + year]["estimate"] else "" entry["wasting"] += "*" if row["details"]["wasting_" + year]["estimate"] else "" # fetch this country's zone for z in zones: if z['code'] == entry["country"]["id"]: entry['zone'] = z['zonecode'] break if not entry.get('zone'): print "No zone match: " + entry["country"]['name'] entry['zone'] = ''