Update test_dataset.py
Browse files- test_dataset.py +18 -12
test_dataset.py
CHANGED
@@ -100,21 +100,27 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
100 |
with open(csvpath, encoding="utf-8") as f:
|
101 |
reader = csv.DictReader(f)
|
102 |
for key, row in enumerate(reader):
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
yield key, {
|
104 |
-
"Year":
|
105 |
-
"Location_Abbr": row
|
106 |
-
"Location_Desc": row
|
107 |
"Geolocation": {
|
108 |
-
"latitude":
|
109 |
-
"longitude":
|
110 |
},
|
111 |
-
"Disease_Type": int(row["Disease_Type"]),
|
112 |
-
"Data_Value_Type": int(row["Data_Value_Type"]),
|
113 |
-
"Data_Value": float(row["Data_Value"]),
|
114 |
-
"Break_Out_Category": row
|
115 |
-
"Break_Out_Details": row
|
116 |
-
"Break_Out_Type": int(row["Break_Out_Type"]),
|
117 |
-
"Life_Expectancy": float(row["Life_Expectancy"]) if row
|
118 |
}
|
119 |
|
120 |
@staticmethod
|
|
|
100 |
with open(csvpath, encoding="utf-8") as f:
|
101 |
reader = csv.DictReader(f)
|
102 |
for key, row in enumerate(reader):
|
103 |
+
year = int(row['Year']) if 'Year' in row else None
|
104 |
+
if 'Geolocation' in row and isinstance(row['Geolocation'], str):
|
105 |
+
geo_str = row['Geolocation'].replace('(', '').replace(')', '')
|
106 |
+
latitude, longitude = map(float, geo_str.split(', '))
|
107 |
+
else:
|
108 |
+
latitude, longitude = None, None
|
109 |
yield key, {
|
110 |
+
"Year": year,
|
111 |
+
"Location_Abbr": row.get('LocationAbbr', None),
|
112 |
+
"Location_Desc": row.get('LocationDesc', None),
|
113 |
"Geolocation": {
|
114 |
+
"latitude": latitude,
|
115 |
+
"longitude": longitude
|
116 |
},
|
117 |
+
"Disease_Type": int(row["Disease_Type"]) if "Disease_Type" in row else None,
|
118 |
+
"Data_Value_Type": int(row["Data_Value_Type"]) if "Data_Value_Type" in row else None,
|
119 |
+
"Data_Value": float(row["Data_Value"]) if "Data_Value" in row else None,
|
120 |
+
"Break_Out_Category": row.get("Break_Out_Category", None),
|
121 |
+
"Break_Out_Details": row.get("Break_Out_Details", None),
|
122 |
+
"Break_Out_Type": int(row["Break_Out_Type"]) if 'Break_Out_Type' in row else None,
|
123 |
+
"Life_Expectancy": float(row["Life_Expectancy"]) if row.get("Life_Expectancy") else None
|
124 |
}
|
125 |
|
126 |
@staticmethod
|