xx103 commited on
Commit
421b86f
1 Parent(s): 07013f8

Update NYC_Motor_Vehicle_Collisions_and_Weather_Dataset.py

Browse files
NYC_Motor_Vehicle_Collisions_and_Weather_Dataset.py CHANGED
@@ -73,27 +73,29 @@ class NYCMotorVehicleCollisionsWeatherDataset(datasets.GeneratorBasedBuilder):
73
  ),
74
  ]
75
 
76
- def _generate_examples(self, filepath):
77
- with open(filepath, encoding="utf-8") as f:
78
- for key, row in enumerate(f):
79
- row = json.loads(line)
80
- yield key, {
81
- "crash_date": row.get("crash_date", ""),
82
- "borough": row.get("borough", ""),
83
- "zip_code": row.get("zip_code", ""),
84
- "latitude": row.get("latitude", None),
85
- "longitude": row.get("longitude", None),
86
- "collision_id": row.get("collision_id", None),
87
- "crash_time_period": row.get("crash_time_period", ""),
88
- "contributing_factor_vehicles": row.get("contributing_factor_vehicles", []),
89
- "vehicle_types": row.get("vehicle_types", []),
90
- "number_of_injuries": row.get("number_of_injuries", None),
91
- "number_of_deaths": row.get("number_of_deaths", None),
92
- "street_name": row.get("street_name", ""),
93
- "street_type": row.get("street_type", ""),
94
- "weather_description": row.get("weather_description", ""),
95
- "precipitation": row.get("precipitation", None),
96
- "precipitation_type": row.get("precipitation_type", ""),
97
- "temp_max": row.get("temp_max", None),
98
- "temp_min": row.get("temp_min", None),
99
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  ),
74
  ]
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
+ def _generate_examples(self, filepath):
78
+ with open(filepath, encoding="utf-8") as f:
79
+ for key, line in enumerate(f): # Corrected variable name here
80
+ row = json.loads(line) # Use 'line' to load JSON
81
+ yield key, {
82
+ "crash_date": row.get("crash_date", ""),
83
+ "borough": row.get("borough", ""),
84
+ "zip_code": row.get("zip_code", ""),
85
+ "latitude": row.get("latitude", None),
86
+ "longitude": row.get("longitude", None),
87
+ "collision_id": row.get("collision_id", None),
88
+ "crash_time_period": row.get("crash_time_period", ""),
89
+ "contributing_factor_vehicles": row.get("contributing_factor_vehicles", []),
90
+ "vehicle_types": row.get("vehicle_types", []),
91
+ "number_of_injuries": row.get("number_of_injuries", None),
92
+ "number_of_deaths": row.get("number_of_deaths", None),
93
+ "street_name": row.get("street_name", ""),
94
+ "street_type": row.get("street_type", ""),
95
+ "weather_description": row.get("weather_description", ""),
96
+ "precipitation": row.get("precipitation", None),
97
+ "precipitation_type": row.get("precipitation_type", ""),
98
+ "temp_max": row.get("temp_max", None),
99
+ "temp_min": row.get("temp_min", None),
100
+ }
101
+