# Can't locate the error in my dataset

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-locate-the-error-in-my-dataset%2F108785%3E%5C
**Category:** Intermediate\
**Created:** [September 26, 2024, 2:07pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-locate-the-error-in-my-dataset%2F108785 "2024-09-26T14:07:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![starkadur](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@starkadur](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fstarkadur)%5C
**Post date:** [September 26, 2024, 2:07pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-locate-the-error-in-my-dataset%2F108785%2F1 "2024-09-26T14:07:17Z")

</div>

I always get the following error when I try to download (or preview) the dataset [arnastofnun/test](https://huggingface.co/datasets/arnastofnun/test).

> Traceback (most recent call last):  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/builder.py”, line 1869, in \_prepare\_split\_single  
> writer.write\_table(table)  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/arrow\_writer.py”, line 580, in write\_table  
> pa\_table = table\_cast(pa\_table, self.\_schema)  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 2292, in table\_cast  
> return cast\_table\_to\_schema(table, schema)  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 2245, in cast\_table\_to\_schema  
> arrays = [  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 2246, in   
> cast\_array\_to\_feature(  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 1795, in wrapper  
> return pa.chunked\_array([func(chunk, \*args, \*\*kwargs) for chunk in array.chunks])  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 1795, in   
> return pa.chunked\_array([func(chunk, \*args, \*\*kwargs) for chunk in array.chunks])  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 2005, in cast\_array\_to\_feature  
> arrays = [  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 2006, in   
> \_c(array.field(name) if name in array\_fields else null\_array, subfeature)  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 1797, in wrapper  
> return func(array, \*args, \*\*kwargs)  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 2102, in cast\_array\_to\_feature  
> return array\_cast(  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 1797, in wrapper  
> return func(array, \*args, \*\*kwargs)  
> File “/home/starkadur/.local/lib/python3.8/site-packages/datasets/table.py”, line 1948, in array\_cast  
> raise TypeError(f"Couldn’t cast array of type {\_short\_str(array.type)} to {\_short\_str(pa\_type)}")  
> TypeError: Couldn’t cast array of type string to null

I have tried to split the dataset up into smaller bits to find out where in the data the problem lies, but if I only upload the first half of the dataset, I don’t get any error, and if I only upload the second half of the data set, I don’t get any error either. So I can’t know where the problem lies in the data. All help is appreciated.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 26, 2024, 3:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-locate-the-error-in-my-dataset%2F108785%2F2 "2024-09-26T15:12:51Z")

</div>

It appears to be a complicated issue that is probably unresolved. A workaround seems to be to pass the dataset as JSON.

> <https://github.com/huggingface/datasets/issues/5422>
>
> \### Describe the bug
> 
> Loading a previously downloaded & saved dataset as descr…ibed in the HuggingFace course:
> 
> issues\_dataset = load\_dataset("json", data\_files="issues/datasets-issues.jsonl", split="train")
> 
> Gives this error:
> datasets.builder.DatasetGenerationError: An error occurred while generating the dataset
> 
> A work-around I found was to use streaming.
> 
> \### Steps to reproduce the bug
> 
> Reproduce by executing the code provided:
> https://huggingface.co/course/chapter5/5?fw=pt
> From the heading:
> 'let’s create a function that can download all the issues from a GitHub repository'
> 
> \### Expected behavior
> 
> No error
> 
> \### Environment info
> 
> Datasets version 2.8.0. Note that version 2.6.1 gives the same error (related to null timestamp).
> 
> \*\*\[EDIT\]\*\*
> 
> This is the complete error trace confirming the issue is related to the timestamp (\`Couldn't cast array of type timestamp\[s\] to null\`)
> 
> \`\`\`
> Using custom data configuration default-950028611d2860c8
> Downloading and preparing dataset json/default to \[...\]/.cache/huggingface/datasets/json/default-950028611d2860c8/0.0.0/0f7e3662623656454fcd2b650f34e886a7db4b9104504885bd462096cc7a9f51...
> Downloading data files: 100%|██████████| 1/1 \[00:00\<?, ?it/s\]
> Extracting data files: 100%|██████████| 1/1 \[00:00\<00:00, 500.63it/s\]
> Generating train split: 2619 examples \[00:00, 7155.72 examples/s\]Traceback (most recent call last):
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\builder.py", line 1831, in \_prepare\_split\_single
> writer.write\_table(table)
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\arrow\_writer.py", line 567, in write\_table
> pa\_table = table\_cast(pa\_table, self.\_schema)
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 2282, in table\_cast
> return cast\_table\_to\_schema(table, schema)
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 2241, in cast\_table\_to\_schema
> arrays = \[cast\_array\_to\_feature(table\[name\], feature) for name, feature in features.items()\]
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 2241, in \<listcomp\>
> arrays = \[cast\_array\_to\_feature(table\[name\], feature) for name, feature in features.items()\]
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 1807, in wrapper
> return pa.chunked\_array(\[func(chunk, \*args, \*\*kwargs) for chunk in array.chunks\])
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 1807, in \<listcomp\>
> return pa.chunked\_array(\[func(chunk, \*args, \*\*kwargs) for chunk in array.chunks\])
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 2035, in cast\_array\_to\_feature
> arrays = \[\_c(array.field(name), subfeature) for name, subfeature in feature.items()\]
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 2035, in \<listcomp\>
> arrays = \[\_c(array.field(name), subfeature) for name, subfeature in feature.items()\]
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 1809, in wrapper
> return func(array, \*args, \*\*kwargs)
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 2101, in cast\_array\_to\_feature
> return array\_cast(array, feature(), allow\_number\_to\_str=allow\_number\_to\_str)
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 1809, in wrapper
> return func(array, \*args, \*\*kwargs)
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\table.py", line 1990, in array\_cast
> raise TypeError(f"Couldn't cast array of type {array.type} to {pa\_type}")
> TypeError: Couldn't cast array of type timestamp\[s\] to null
> The above exception was the direct cause of the following exception:
> Traceback (most recent call last):
> File "C:\\Program Files\\JetBrains\\PyCharm 2022.1.3\\plugins\\python\\helpers\\pydev\\pydevconsole.py", line 364, in runcode
> coro = func()
> File "\<input\>", line 1, in \<module\>
> File "C:\\Program Files\\JetBrains\\PyCharm 2022.1.3\\plugins\\python\\helpers\\pydev\\\_pydev\_bundle\\pydev\_umd.py", line 198, in runfile
> pydev\_imports.execfile(filename, global\_vars, local\_vars) # execute the script
> File "C:\\Program Files\\JetBrains\\PyCharm 2022.1.3\\plugins\\python\\helpers\\pydev\\\_pydev\_imps\\\_pydev\_execfile.py", line 18, in execfile
> exec(compile(contents+"\\n", file, 'exec'), glob, loc)
> File "\[...\]\\PycharmProjects\\TransformersTesting\\dataset\_issues.py", line 20, in \<module\>
> issues\_dataset = load\_dataset("json", data\_files="issues/datasets-issues.jsonl", split="train")
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\load.py", line 1757, in load\_dataset
> builder\_instance.download\_and\_prepare(
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\builder.py", line 860, in download\_and\_prepare
> self.\_download\_and\_prepare(
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\builder.py", line 953, in \_download\_and\_prepare
> self.\_prepare\_split(split\_generator, \*\*prepare\_split\_kwargs)
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\builder.py", line 1706, in \_prepare\_split
> for job\_id, done, content in self.\_prepare\_split\_single(
> File "\[...\]\\miniconda3\\envs\\HuggingFace\\lib\\site-packages\\datasets\\builder.py", line 1849, in \_prepare\_split\_single
> raise DatasetGenerationError("An error occurred while generating the dataset") from e
> datasets.builder.DatasetGenerationError: An error occurred while generating the dataset
> Generating train split: 2619 examples \[00:19, 7155.72 examples/s\]
> \`\`\`

> <https://github.com/THUDM/LongBench/issues/52>
>
> 服务器没办法链接huggingface，只是将pred.py中THU/Longbench的路径换成了本地的/home/eval/LongBench/data,c…onfig文件中的模型路径也已经添加，报错如下
> CUDA\_VISIBLE\_DEVICES=7 python pred.py --model llama2-13b-chat-16k
> Resolving data files: 100%|████████████████████████████████████| 34/34 \[00:00\<00:00, 149169.81it/s\]
> Downloading data files: 100%|██████████████████████████████████████| 1/1 \[00:00\<00:00, 1417.95it/s\]
> Extracting data files: 100%|█████████████████████████████████████████| 1/1 \[00:00\<00:00, 87.24it/s\]
> Generating train split: 2500 examples \[00:00, 4816.93 examples/s\]
> Traceback (most recent call last):
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/builder.py", line 1940, in \_prepare\_split\_single
> writer.write\_table(table)
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/arrow\_writer.py", line 572, in write\_table
> pa\_table = table\_cast(pa\_table, self.\_schema)
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/table.py", line 2328, in table\_cast
> return cast\_table\_to\_schema(table, schema)
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/table.py", line 2287, in cast\_table\_to\_schema
> arrays = \[cast\_array\_to\_feature(table\[name\], feature) for name, feature in features.items()\]
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/table.py", line 2287, in \<listcomp\>
> arrays = \[cast\_array\_to\_feature(table\[name\], feature) for name, feature in features.items()\]
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/table.py", line 1831, in wrapper
> return pa.chunked\_array(\[func(chunk, \*args, \*\*kwargs) for chunk in array.chunks\])
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/table.py", line 1831, in \<listcomp\>
> return pa.chunked\_array(\[func(chunk, \*args, \*\*kwargs) for chunk in array.chunks\])
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/table.py", line 2143, in cast\_array\_to\_feature
> return array\_cast(array, feature(), allow\_number\_to\_str=allow\_number\_to\_str)
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/table.py", line 1833, in wrapper
> return func(array, \*args, \*\*kwargs)
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/table.py", line 2028, in array\_cast
> raise TypeError(f"Couldn't cast array of type\\n{array.type}\\nto\\n{pa\_type}")
> TypeError: Couldn't cast array of type
> list\<item: string\>
> to
> null
> 
> The above exception was the direct cause of the following exception:
> 
> Traceback (most recent call last):
> File "/root/zyx/eval/LongBench/pred.py", line 163, in \<module\>
> data = load\_dataset('/root/zyx/eval/LongBench/data/data', dataset, split='test')
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/load.py", line 2153, in load\_dataset
> builder\_instance.download\_and\_prepare(
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/builder.py", line 954, in download\_and\_prepare
> self.\_download\_and\_prepare(
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/builder.py", line 1049, in \_download\_and\_prepare
> self.\_prepare\_split(split\_generator, \*\*prepare\_split\_kwargs)
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/builder.py", line 1813, in \_prepare\_split
> for job\_id, done, content in self.\_prepare\_split\_single(
> File "/root/miniconda3/envs/zyx/lib/python3.10/site-packages/datasets/builder.py", line 1958, in \_prepare\_split\_single
> raise DatasetGenerationError("An error occurred while generating the dataset") from e
> datasets.builder.DatasetGenerationError: An error occurred while generating the dataset
> 
> 请问如何解决呢

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [September 27, 2024, 6:41am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-locate-the-error-in-my-dataset%2F108785%2F3 "2024-09-27T06:41:34Z")

</div>

Hi,

This is because the author has just uploaded a zip file to the dataset repo: [arnastofnun/test at main](https://huggingface.co/datasets/arnastofnun/test/tree/main), hence one would need to unzip it locally. Here’s how to download the file:

```python
from huggingface_hub import hf_hub_download

filepath = hf_hub_download(repo_id="arnastofnun/test", filename="igc_news1_eidfaxi.zip", repo_type="dataset")

```

---

<div class="post-metadata">

**Author:** ![starkadur](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@starkadur](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fstarkadur)%5C
**Post date:** [September 30, 2024, 7:59am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-locate-the-error-in-my-dataset%2F108785%2F4 "2024-09-30T07:59:33Z")

</div>

Thank your for your answer.  
I have tried to upload the file unzipped. I have deleted the zip-file and uploaded the jsonl-file, but the error remains. Actually this dataset is a snippet of a much larger dataset (arnastofnun/IGC-2022-1) with tens of much bigger zip-files, and there I only have this problem with three of the files. So it seems that the zip-files are not the problem.
