Handle empty input in rows_from_file

This commit is contained in:
Rami Abdelrazzaq 2026-08-12 13:06:25 -05:00
commit b143fc4913
2 changed files with 9 additions and 0 deletions

View file

@ -368,6 +368,8 @@ def rows_from_file(
raise TypeError(
"rows_from_file() requires a file-like object that supports peek(), such as io.BytesIO"
)
if not first_bytes:
return (), Format.CSV
if first_bytes.startswith((b"[", b"{")):
# TODO: Detect newline-JSON
return rows_from_file(buffered, format=Format.JSON)