diff --git a/AUTHORS.rst b/AUTHORS.rst index 7fc88e3..d6014b4 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -53,3 +53,4 @@ agate is made by a community. The following individuals have contributed code, d * `Karthik Ramadugu `__ * `Josh Renaud `__ * `Vincent Gao `__ +* `Sanjay Santhanam `__ diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f5824fa..e0acb44 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,7 @@ - fix: :meth:`.Table.distinct` now deduplicates rows when ``key`` is a sequence of column names. - fix: :class:`.Rank` ranks null values last when ``reverse=True``. +- fix: :meth:`.Table.from_fixed` reads the schema instead of the data file when ``schema_path`` is a file-like object. 1.14.2 - February 27, 2026 -------------------------- diff --git a/agate/table/from_fixed.py b/agate/table/from_fixed.py index 08ad9a0..7f0d929 100644 --- a/agate/table/from_fixed.py +++ b/agate/table/from_fixed.py @@ -47,7 +47,7 @@ def from_fixed(cls, path, schema_path, column_names=utils.default, column_types= schema_f = open(schema_path, encoding=schema_encoding) close_schema_f = True else: - schema_f = path + schema_f = schema_path reader = fixed.reader(f, schema_f) rows = list(reader) diff --git a/tests/test_table/test_from_fixed.py b/tests/test_table/test_from_fixed.py index a546125..ed001c6 100644 --- a/tests/test_table/test_from_fixed.py +++ b/tests/test_table/test_from_fixed.py @@ -11,3 +11,15 @@ def test_from_fixed(self): self.assertColumnTypes(table2, [type(c) for c in table1.column_types]) self.assertRows(table2, table1.rows) + + def test_from_fixed_file_like_objects(self): + table1 = Table.from_csv('examples/testfixed_converted.csv') + + with open('examples/testfixed', encoding='utf-8') as f, \ + open('examples/testfixed_schema.csv', encoding='utf-8') as schema_f: + table2 = Table.from_fixed(f, schema_f) + + self.assertColumnNames(table2, table1.column_names) + self.assertColumnTypes(table2, [type(c) for c in table1.column_types]) + + self.assertRows(table2, table1.rows)