From be4fa7d76d2674c02b0b9a75620054f274fe5887 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Sun, 28 Apr 2024 00:20:52 -0400 Subject: [PATCH] fix: Seek to the original offset 1db7277 --- CHANGELOG.rst | 1 + agate/table/from_csv.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 31eb0fc..e84bdc5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,7 @@ 1.10.1 - April 27, 2024 ----------------------- +- fix: Version 1.10.0 seeks to the file's beginning, instead of to the original offset. - fix: :meth:`.Number.csvify` returns a ``Decimal`` (or ``None``), instead of ``str``. :meth:`.Table.to_csv` with ``quoting=csv.QUOTE_NONNUMERIC`` now works. 1.10.0 - April 27, 2024 diff --git a/agate/table/from_csv.py b/agate/table/from_csv.py index ad445c8..860f473 100644 --- a/agate/table/from_csv.py +++ b/agate/table/from_csv.py @@ -66,9 +66,11 @@ def from_csv(cls, path, column_names=None, column_types=None, row_names=None, sk handle = StringIO(f.read()) kwargs['dialect'] = csv.Sniffer().sniff(handle.getvalue()) elif sniff_limit > 0: + offset = f.tell() + # Reads only the start of the file. kwargs['dialect'] = csv.Sniffer().sniff(f.read(sniff_limit)) - f.seek(0) + f.seek(offset) reader = csv.reader(handle, header=header, **kwargs)