Handle empty input in rows_from_file

Closes #808
This commit is contained in:
Rami Abdelrazzaq 2026-08-12 16:05:09 -05:00 committed by GitHub
commit 25c632fbbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -373,6 +373,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)