Allow pathlib PoxisPath in Dataset.read_json
NONE
This same error will occur using `ds = datasets.load_dataset('json', data_files=['test.jsonl'])`
2023-03-02T11:50:26Z
https://github.com/huggingface/datasets/issues/4864#issuecomment-1451743319
https://api.github.com/repos/huggingface/datasets/issues/4864
IC_kwDODunzps5Wh9hX
https://api.github.com/repos/huggingface/datasets/issues/comments/1451743319/reactions
2023-03-02T11:50:26Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1451743319
https://avatars.githubusercontent.com/u/44398246?v=4
https://api.github.com/users/vvvm23/events{/privacy}
https://api.github.com/users/vvvm23/followers
https://api.github.com/users/vvvm23/following{/other_user}
https://api.github.com/users/vvvm23/gists{/gist_id}
https://github.com/vvvm23
vvvm23
MDQ6VXNlcjQ0Mzk4MjQ2
https://api.github.com/users/vvvm23/orgs
https://api.github.com/users/vvvm23/received_events
https://api.github.com/users/vvvm23/repos
https://api.github.com/users/vvvm23/starred{/owner}{/repo}
https://api.github.com/users/vvvm23/subscriptions
User
https://api.github.com/users/vvvm23
public
NONE
@cccntu I want to make a quick fix for this, but I am struggling to find where the json dataset builder is. Do you know?
2023-03-09T18:54:21Z
https://github.com/huggingface/datasets/issues/4864#issuecomment-1462598366
https://api.github.com/repos/huggingface/datasets/issues/4864
IC_kwDODunzps5XLXre
https://api.github.com/repos/huggingface/datasets/issues/comments/1462598366/reactions
2023-03-09T18:54:21Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1462598366
https://avatars.githubusercontent.com/u/44398246?v=4
https://api.github.com/users/vvvm23/events{/privacy}
https://api.github.com/users/vvvm23/followers
https://api.github.com/users/vvvm23/following{/other_user}
https://api.github.com/users/vvvm23/gists{/gist_id}
https://github.com/vvvm23
vvvm23
MDQ6VXNlcjQ0Mzk4MjQ2
https://api.github.com/users/vvvm23/orgs
https://api.github.com/users/vvvm23/received_events
https://api.github.com/users/vvvm23/repos
https://api.github.com/users/vvvm23/starred{/owner}{/repo}
https://api.github.com/users/vvvm23/subscriptions
User
https://api.github.com/users/vvvm23
public
CONTRIBUTOR
@vvvm23 I think you mean think:
```python
ds = datasets.load_dataset('json', data_files=[Path('test.jsonl')])
```
And the place you want to modify is here:
```
utils/file_utils.py:64, in is_remote_url(url_or_filename)
     63 def is_remote_url(url_or_filename: str) -> bool:
---> 64     parsed = urlparse(url_or_filename)
     65     return parsed.scheme in ("http", "https", "s3", "gs", "hdfs", "ftp")
```

Probably just need to check first if `url_or_filename` is [PathLike](https://docs.python.org/3/library/os.html#os.PathLike) and return False early.

Btw, I tried installing from main, and ran my code above and got a different error. Probably because the API have changed.
`AttributeError: module 'datasets' has no attribute 'read_json'`

2023-03-10T01:40:48Z
https://github.com/huggingface/datasets/issues/4864#issuecomment-1463081402
https://api.github.com/repos/huggingface/datasets/issues/4864
IC_kwDODunzps5XNNm6
https://api.github.com/repos/huggingface/datasets/issues/comments/1463081402/reactions
2023-03-10T01:40:48Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1463081402
https://avatars.githubusercontent.com/u/31893406?v=4
https://api.github.com/users/changjonathanc/events{/privacy}
https://api.github.com/users/changjonathanc/followers
https://api.github.com/users/changjonathanc/following{/other_user}
https://api.github.com/users/changjonathanc/gists{/gist_id}
https://github.com/changjonathanc
changjonathanc
MDQ6VXNlcjMxODkzNDA2
https://api.github.com/users/changjonathanc/orgs
https://api.github.com/users/changjonathanc/received_events
https://api.github.com/users/changjonathanc/repos
https://api.github.com/users/changjonathanc/starred{/owner}{/repo}
https://api.github.com/users/changjonathanc/subscriptions
User
https://api.github.com/users/changjonathanc
public
NONE
> @vvvm23 I think you mean think:

You are correct, thanks!

> Probably just need to check first if url_or_filename is [PathLike](https://docs.python.org/3/library/os.html#os.PathLike) and return False early.

Is PathLike sufficient, or should I check the file exists here? Or is that handled later?
2023-03-10T19:35:21Z
https://github.com/huggingface/datasets/issues/4864#issuecomment-1464312629
https://api.github.com/repos/huggingface/datasets/issues/4864
IC_kwDODunzps5XR6M1
https://api.github.com/repos/huggingface/datasets/issues/comments/1464312629/reactions
2023-03-10T19:35:30Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1464312629
https://avatars.githubusercontent.com/u/44398246?v=4
https://api.github.com/users/vvvm23/events{/privacy}
https://api.github.com/users/vvvm23/followers
https://api.github.com/users/vvvm23/following{/other_user}
https://api.github.com/users/vvvm23/gists{/gist_id}
https://github.com/vvvm23
vvvm23
MDQ6VXNlcjQ0Mzk4MjQ2
https://api.github.com/users/vvvm23/orgs
https://api.github.com/users/vvvm23/received_events
https://api.github.com/users/vvvm23/repos
https://api.github.com/users/vvvm23/starred{/owner}{/repo}
https://api.github.com/users/vvvm23/subscriptions
User
https://api.github.com/users/vvvm23
public
CONTRIBUTOR
I think here we just want to avoid passing Path to urlparse. A simpler solution is to add a str() call and convert the input to string before passing to the next step. No need to check anything.
2023-03-11T05:46:51Z
https://github.com/huggingface/datasets/issues/4864#issuecomment-1464834467
https://api.github.com/repos/huggingface/datasets/issues/4864
IC_kwDODunzps5XT5mj
https://api.github.com/repos/huggingface/datasets/issues/comments/1464834467/reactions
2023-03-11T05:46:51Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1464834467
https://avatars.githubusercontent.com/u/31893406?v=4
https://api.github.com/users/changjonathanc/events{/privacy}
https://api.github.com/users/changjonathanc/followers
https://api.github.com/users/changjonathanc/following{/other_user}
https://api.github.com/users/changjonathanc/gists{/gist_id}
https://github.com/changjonathanc
changjonathanc
MDQ6VXNlcjMxODkzNDA2
https://api.github.com/users/changjonathanc/orgs
https://api.github.com/users/changjonathanc/received_events
https://api.github.com/users/changjonathanc/repos
https://api.github.com/users/changjonathanc/starred{/owner}{/repo}
https://api.github.com/users/changjonathanc/subscriptions
User
https://api.github.com/users/changjonathanc
public
NONE
Above PR should do your first suggestion. Hope that works for you, as I am going on holiday and won't be able to change much :wink: 
2023-03-12T11:25:49Z
https://github.com/huggingface/datasets/issues/4864#issuecomment-1465167376
https://api.github.com/repos/huggingface/datasets/issues/4864
IC_kwDODunzps5XVK4Q
https://api.github.com/repos/huggingface/datasets/issues/comments/1465167376/reactions
2023-03-12T11:25:49Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1465167376
https://avatars.githubusercontent.com/u/44398246?v=4
https://api.github.com/users/vvvm23/events{/privacy}
https://api.github.com/users/vvvm23/followers
https://api.github.com/users/vvvm23/following{/other_user}
https://api.github.com/users/vvvm23/gists{/gist_id}
https://github.com/vvvm23
vvvm23
MDQ6VXNlcjQ0Mzk4MjQ2
https://api.github.com/users/vvvm23/orgs
https://api.github.com/users/vvvm23/received_events
https://api.github.com/users/vvvm23/repos
https://api.github.com/users/vvvm23/starred{/owner}{/repo}
https://api.github.com/users/vvvm23/subscriptions
User
https://api.github.com/users/vvvm23
public
NONE
I just came across this problem with `DatasetDict.from_parquet()`. The error still seems to originate from the same place:
```
  File "/usr/local/lib/python3.12/dist-packages/datasets/utils/file_utils.py", line 88, in is_relative_path
    return urlparse(url_or_filename).scheme == "" and not os.path.isabs(url_or_filename)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
```
The PR looks like it would still solve everything. Is there a reason this got delayed?
2025-04-11T17:22:46Z
https://github.com/huggingface/datasets/issues/4864#issuecomment-2797546074
https://api.github.com/repos/huggingface/datasets/issues/4864
IC_kwDODunzps6mvypa
https://api.github.com/repos/huggingface/datasets/issues/comments/2797546074/reactions
2025-04-11T17:22:46Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2797546074
https://avatars.githubusercontent.com/u/28529410?v=4
https://api.github.com/users/tsteffek/events{/privacy}
https://api.github.com/users/tsteffek/followers
https://api.github.com/users/tsteffek/following{/other_user}
https://api.github.com/users/tsteffek/gists{/gist_id}
https://github.com/tsteffek
tsteffek
MDQ6VXNlcjI4NTI5NDEw
https://api.github.com/users/tsteffek/orgs
https://api.github.com/users/tsteffek/received_events
https://api.github.com/users/tsteffek/repos
https://api.github.com/users/tsteffek/starred{/owner}{/repo}
https://api.github.com/users/tsteffek/subscriptions
User
https://api.github.com/users/tsteffek
public
**Is your feature request related to a problem? Please describe.**
```
from pathlib import Path
from datasets import Dataset
ds = Dataset.read_json(Path('data.json'))
```
causes an error
```
AttributeError: 'PosixPath' object has no attribute 'decode'
```

**Describe the solution you'd like**

It should be able to accept PosixPath and read the json from inside.