-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix KeyError parsing for Cuba #2778
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,16 +161,23 @@ def parse_cases(raw_data_file, source_id, source_url): | |
# First make dict mapping code names of diagnostic and treament centers | ||
# to actual locations | ||
hospital_map = {} | ||
for centre_type in ['centros_aislamiento', 'centros_diagnostico']: | ||
for centre in json_data[centre_type]: | ||
hospital_map[centre] = json_data[centre_type][centre]['nombre'] + \ | ||
", " + json_data[centre_type][centre]['provincia'] | ||
try: | ||
for centre_type in ['centros_aislamiento', 'centros_diagnostico']: | ||
for centre in json_data[centre_type]: | ||
hospital_map[centre] = json_data[centre_type][centre]['nombre'] + \ | ||
", " + json_data[centre_type][centre]['provincia'] | ||
except: | ||
#key not found | ||
pass | ||
|
||
# Get schema_version | ||
schema_version = json_data['schema-version'] | ||
if schema_version != 7: | ||
logger.warning( | ||
f'Schema version has been updated from 7 to {schema_version}') | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was schema-version removed? A change in schema-version should break the script, as we might not be capturing the correct fields. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. schema-version was removed. There is no mention of schema-version in covid19-cuba-1.json. |
||
schema_version = json_data['schema-version'] | ||
if schema_version != 7: | ||
logger.warning( | ||
f'Schema version has been updated from 7 to {schema_version}') | ||
except: | ||
schema_version = "(undef)" | ||
|
||
for day in json_data['casos']['dias']: | ||
if 'diagnosticados' in json_data['casos']['dias'][day]: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use except KeyError here - in case some other exception is raised. Also good to use logging.info to print a message saying that key was not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New commit [6c96b56] deals with this.