@@ -170,7 +170,11 @@ def extract_and_check_row(row, geo_type):
170170
171171 if geo_type in ('hrr' , 'msa' , 'dma' ):
172172 # these particular ids are prone to be written as ints -- and floats
173- geo_id = str (CsvImporter .floaty_int (geo_id ))
173+ try :
174+ geo_id = str (CsvImporter .floaty_int (geo_id ))
175+ except ValueError :
176+ # expected a number, but got a string
177+ return (None , 'geo_id' )
174178
175179 # sanity check geo_id with respect to geo_type
176180 if geo_type == 'county' :
@@ -207,12 +211,20 @@ def extract_and_check_row(row, geo_type):
207211 return (None , 'val' )
208212
209213 # optional nonnegative float
210- stderr = CsvImporter .maybe_apply (float , row .se )
214+ try :
215+ stderr = CsvImporter .maybe_apply (float , row .se )
216+ except ValueError :
217+ # expected a number, but got a string
218+ return (None , 'se' )
211219 if stderr is not None and stderr < 0 :
212220 return (None , 'se' )
213221
214222 # optional not-too-small float
215- sample_size = CsvImporter .maybe_apply (float , row .sample_size )
223+ try :
224+ sample_size = CsvImporter .maybe_apply (float , row .sample_size )
225+ except ValueError :
226+ # expected a number, but got a string
227+ return (None , 'sample_size' )
216228 if sample_size is not None and sample_size < CsvImporter .MIN_SAMPLE_SIZE :
217229 return (None , 'sample_size' )
218230
0 commit comments