Catch ValueError on invalid integers in storm report details
This commit is contained in:
parent
01fe9f53c9
commit
ccade2a91d
1 changed files with 14 additions and 3 deletions
|
@ -107,8 +107,6 @@ class StormReport():
|
||||||
|
|
||||||
report.timestamp_start = timestamp_from_parts(tz, row['BEGIN_YEARMONTH'], row['BEGIN_DAY'], row['BEGIN_TIME'])
|
report.timestamp_start = timestamp_from_parts(tz, row['BEGIN_YEARMONTH'], row['BEGIN_DAY'], row['BEGIN_TIME'])
|
||||||
report.timestamp_end = timestamp_from_parts(tz, row['END_YEARMONTH'], row['END_DAY'], row['END_TIME'])
|
report.timestamp_end = timestamp_from_parts(tz, row['END_YEARMONTH'], row['END_DAY'], row['END_TIME'])
|
||||||
report.episode_id = int(row['EPISODE_ID'])
|
|
||||||
report.event_id = int(row['EVENT_ID'])
|
|
||||||
report.state = row['STATE']
|
report.state = row['STATE']
|
||||||
report.event_type = row['EVENT_TYPE']
|
report.event_type = row['EVENT_TYPE']
|
||||||
report.wfo = row['WFO']
|
report.wfo = row['WFO']
|
||||||
|
@ -118,6 +116,16 @@ class StormReport():
|
||||||
report.locale_end = row['END_LOCATION']
|
report.locale_end = row['END_LOCATION']
|
||||||
report.tornado_f_rating = row['TOR_F_SCALE']
|
report.tornado_f_rating = row['TOR_F_SCALE']
|
||||||
|
|
||||||
|
try:
|
||||||
|
report.episode_id = int(row['EPISODE_ID'])
|
||||||
|
except ValueError:
|
||||||
|
report.episode_id = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
report.event_id = int(row['EVENT_ID'])
|
||||||
|
except ValueError:
|
||||||
|
report.event_id = None
|
||||||
|
|
||||||
return report
|
return report
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -126,7 +134,10 @@ class StormReport():
|
||||||
reader = csv.DictReader(fh, dialect='excel')
|
reader = csv.DictReader(fh, dialect='excel')
|
||||||
|
|
||||||
for row in reader:
|
for row in reader:
|
||||||
yield StormReport.from_csv_row(row)
|
try:
|
||||||
|
yield StormReport.from_csv_row(row)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
RADAR_SIGNIFICANT_EVENT_TYPES = {
|
RADAR_SIGNIFICANT_EVENT_TYPES = {
|
||||||
'Blizzard': True,
|
'Blizzard': True,
|
||||||
|
|
Loading…
Add table
Reference in a new issue