Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/datasets/io/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ def write(self) -> int:
if compression not in [None, "infer", "gzip", "bz2", "xz"]:
raise NotImplementedError(f"`datasets` currently does not support {compression} compression")

if not lines and self.batch_size < self.dataset.num_rows:
raise NotImplementedError(
"Output JSON will not be formatted correctly when lines = False and batch_size < number of rows in the dataset. Use pandas.DataFrame.to_json() instead."
)
if not lines:
# lines=False requires a single JSON array - force batch_size to cover all rows
self.batch_size = self.dataset.num_rows

if isinstance(self.path_or_buf, (str, bytes, os.PathLike)):
with fsspec.open(
Expand Down