xx103 commited on
Commit
1a150d2
1 Parent(s): 10e41ee

Update NYC_Motor_Vehicle_Collisions_and_Weather_Dataset.py

Browse files
NYC_Motor_Vehicle_Collisions_and_Weather_Dataset.py CHANGED
@@ -77,27 +77,26 @@ class NYCMotorVehicleCollisionsWeatherDataset(datasets.GeneratorBasedBuilder):
77
 
78
  def _generate_examples(self, filepath):
79
  with open(filepath, encoding="utf-8") as f:
80
- for key, line in enumerate(f): # Corrected variable name here
81
- row = json.loads(line) # Use 'line' to load JSON
82
  yield key, {
83
- "crash_date": row.get("crash_date", ""),
84
- "borough": row.get("borough", ""),
85
- "zip_code": row.get("zip_code", ""),
86
- "latitude": row.get("latitude", None),
87
- "longitude": row.get("longitude", None),
88
- "collision_id": row.get("collision_id", None),
89
- "crash_time_period": row.get("crash_time_period", ""),
90
- "contributing_factor_vehicles": row.get("contributing_factor_vehicles", []),
91
- "vehicle_types": row.get("vehicle_types", []),
92
- "number_of_injuries": row.get("number_of_injuries", None),
93
- "number_of_deaths": row.get("number_of_deaths", None),
94
- "street_name": row.get("street_name", ""),
95
- "street_type": row.get("street_type", ""),
96
- "weather_description": row.get("weather_description", ""),
97
- "precipitation": row.get("precipitation", None),
98
- "precipitation_type": row.get("precipitation_type", ""),
99
- "temp_max": row.get("temp_max", None),
100
- "temp_min": row.get("temp_min", None),
101
  }
102
 
103
-
 
77
 
78
  def _generate_examples(self, filepath):
79
  with open(filepath, encoding="utf-8") as f:
80
+ for key, line in enumerate(f):
81
+ row = json.loads(line)
82
  yield key, {
83
+ "crash_date": row.get("CRASH DATE", ""),
84
+ "borough": row.get("BOROUGH", ""),
85
+ "zip_code": row.get("ZIP CODE", ""),
86
+ "latitude": row.get("LATITUDE", None),
87
+ "longitude": row.get("LONGITUDE", None),
88
+ "collision_id": row.get("COLLISION_ID", None),
89
+ "crash_time_period": row.get("CRASH TIME PERIOD", ""),
90
+ "contributing_factor_vehicles": row.get("CONTRIBUTING FACTOR VEHICLES", "").split(", "),
91
+ "vehicle_types": row.get("VEHICLE TYPES", "").split(", "),
92
+ "number_of_injuries": row.get("NUMBER OF INJURIES", None),
93
+ "number_of_deaths": row.get("NUMBER OF DEATHS", None),
94
+ "street_name": row.get("STREET NAME", ""),
95
+ "street_type": row.get("STREET TYPE", ""),
96
+ "weather_description": row.get("WEATHER DESCRIPTION", ""),
97
+ "precipitation": row.get("PRECIPITATION", None),
98
+ "precipitation_type": row.get("PRECIPITATION TYPE", ""),
99
+ "temp_max": row.get("TEMPMAX", None),
100
+ "temp_min": row.get("TEMPMIN", None),
101
  }
102