@@ -19,10 +19,14 @@ def load_data(project_id: str, gzipped_csv_file: str) -> list:
1919 project_data = []
2020 with gzip .open (gzipped_csv_file , mode = "rt" ) as f :
2121 reader = csv .reader (f , delimiter = "," )
22+ column_index_map = {}
2223
2324 for i , row in enumerate (reader ):
2425 if i == 0 :
2526 # skip header
27+ column_index_map = {
28+ column_label : index for index , column_label in enumerate (row )
29+ }
2630 continue
2731
2832 # the last row of the csv might contain a comment about data use
@@ -42,14 +46,15 @@ def load_data(project_id: str, gzipped_csv_file: str) -> list:
4246 "task_x" : task_x ,
4347 "task_y" : task_y ,
4448 "task_z" : task_z ,
45- "no_count" : int (row [2 ]),
46- "yes_count" : int (row [3 ]),
47- "maybe_count" : int (row [4 ]),
48- "bad_imagery_count" : int (row [5 ]),
49- "no_share" : float (row [7 ]),
50- "yes_share" : float (row [8 ]),
51- "maybe_share" : float (row [9 ]),
52- "bad_imagery_share" : float (row [10 ]),
49+ # XXX: Assuming 0->No, 1->Yes, 2->Maybe, 3->Bad
50+ "no_count" : int (column_index_map .get ("0_count" , 0 )),
51+ "yes_count" : int (column_index_map .get ("1_count" , 0 )),
52+ "maybe_count" : int (column_index_map .get ("2_count" , 0 )),
53+ "bad_imagery_count" : int (column_index_map .get ("3_count" , 0 )),
54+ "no_share" : float (column_index_map .get ("0_count" , 0 )),
55+ "yes_share" : float (column_index_map .get ("1_count" , 0 )),
56+ "maybe_share" : float (column_index_map .get ("2_count" , 0 )),
57+ "bad_imagery_share" : float (column_index_map .get ("3_count" , 0 )),
5358 "wkt" : tile_functions .geometry_from_tile_coords (
5459 task_x , task_y , task_z
5560 ),
0 commit comments