ArrowInvalid Exception: Failed to parse string: '' as a scalar of type timestamp[s]
#2
by
RaymondAISG
- opened
Tried loading the dataset via the following:
from datasets import load_dataset
data = load_dataset("common-pile/foodista_filtered")
Ended up with the following exception:
ArrowInvalid: Failed to parse string: '' as a scalar of type timestamp[s]
The above exception was the direct cause of the following exception:
DatasetGenerationError Traceback (most recent call last)
Cell In[2], line 1
----> 1 data = load_dataset("common-pile/foodista_filtered")
Hi, I ran into the same error when calling load_dataset("common-pile/foodista_filtered").
After checking the raw JSON file (foodista-dolma-0000.json.gz), I found that the field created contains empty strings ("").
In my case, it was 4090 out of 65640 rows.
As a workaround, I replaced "" with null before constructing the dataset.
Using the code below, I was able to load the data successfully:
import gzip
import json
from datasets import Dataset
rows = []
with gzip.open("foodista-dolma-0000.json.gz", "rt", encoding="utf-8") as f:
for line in f:
row = json.loads(line)
if "created" in row and row["created"] == "":
row["created"] = None
rows.append(row)
ds = Dataset.from_list(rows)