From 2a750dbb3818daa1473ed7a204fe6451a737b68a Mon Sep 17 00:00:00 2001 From: Marvin Klerx Date: Fri, 14 Nov 2025 15:33:54 +0100 Subject: [PATCH] fix: fixed duplicated removal of first index / header --- src/Tables/utils/file_reader.py | 2 - tests/atest/test_reader.robot | 55 ++++++++++++++++++++++++++ tests/atest/testdata/example_07.csv | 60 +++++++++++++++++++++++++++++ tests/atest/testdata/example_08.csv | 59 ++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 tests/atest/testdata/example_07.csv create mode 100644 tests/atest/testdata/example_08.csv diff --git a/src/Tables/utils/file_reader.py b/src/Tables/utils/file_reader.py index 3cdf24eb..b7adb74a 100644 --- a/src/Tables/utils/file_reader.py +++ b/src/Tables/utils/file_reader.py @@ -43,8 +43,6 @@ def convert_dataframe( if self.file_type == FileType.Parquet and not self.ignore_header: list_data.insert(0, list(data.columns)) - if self.ignore_header and self.file_type != FileType.Parquet: - return list_data[1:] return list_data if return_type == TableFormat["List of dicts"]: df_for_dicts = data diff --git a/tests/atest/test_reader.robot b/tests/atest/test_reader.robot index 3fd9ef7f..52da056a 100644 --- a/tests/atest/test_reader.robot +++ b/tests/atest/test_reader.robot @@ -107,6 +107,61 @@ Read Row Count - CSV - With Header ${row_count} Tables.Count Table ${file_path} Rows BuiltIn.Should Be Equal ${row_count} ${6} + +# Check reading and opening of CSV file with ignore header true and false +CSV has Headers - Read CSV Table and Ignore Header + Tables.Configure Ignore Header ${True} + Tables.Count Table ${CURDIR}${/}testdata${/}example_07.csv Rows == ${57} + ${data} = Tables.Read Table ${CURDIR}${/}testdata${/}example_07.csv + Length Should Be ${data} ${57} + +CSV has Headers - Open CSV Table and Ignore Header + Tables.Configure Ignore Header ${True} + ${alias} = Tables.Open Table ${CURDIR}${/}testdata${/}example_07.csv + Tables.Count Table ${alias} Rows == ${57} + ${data} = Tables.Get Table + Length Should Be ${data} ${57} + +CSV has Headers - Read CSV Table and Not Ignore Header + Tables.Configure Ignore Header ${False} + Tables.Count Table ${CURDIR}${/}testdata${/}example_07.csv Rows == ${58} + ${data} = Tables.Read Table ${CURDIR}${/}testdata${/}example_07.csv + Length Should Be ${data} ${58} + +CSV has Headers - Open CSV Table and Not Ignore Header + Tables.Configure Ignore Header ${False} + ${alias} = Tables.Open Table ${CURDIR}${/}testdata${/}example_07.csv + Tables.Count Table ${alias} Rows == ${58} + ${data} = Tables.Get Table + Length Should Be ${data} ${58} + +# No headers in file! +CSV has No Headers - Read CSV Table and Ignore Header + Tables.Configure Ignore Header ${True} + Tables.Count Table ${CURDIR}${/}testdata${/}example_08.csv Rows == ${56} + ${data} = Tables.Read Table ${CURDIR}${/}testdata${/}example_08.csv + Length Should Be ${data} ${56} + +CSV has No Headers - Open CSV Table and Ignore Header + Tables.Configure Ignore Header ${True} + ${alias} = Tables.Open Table ${CURDIR}${/}testdata${/}example_08.csv + Tables.Count Table ${alias} Rows == ${56} + ${data} = Tables.Get Table + Length Should Be ${data} ${56} + +CSV has No Headers - Read CSV Table and Not Ignore Header + Tables.Configure Ignore Header ${False} + Tables.Count Table ${CURDIR}${/}testdata${/}example_08.csv Rows == ${57} + ${data} = Tables.Read Table ${CURDIR}${/}testdata${/}example_08.csv + Length Should Be ${data} ${57} + +CSV has No Headers - Open CSV Table and Not Ignore Header + Tables.Configure Ignore Header ${False} + ${alias} = Tables.Open Table ${CURDIR}${/}testdata${/}example_08.csv + Tables.Count Table ${alias} Rows == ${57} + ${data} = Tables.Get Table + Length Should Be ${data} ${57} + ######################################################################################## # TXT ######################################################################################## diff --git a/tests/atest/testdata/example_07.csv b/tests/atest/testdata/example_07.csv new file mode 100644 index 00000000..816f1edf --- /dev/null +++ b/tests/atest/testdata/example_07.csv @@ -0,0 +1,60 @@ +Timestamp,Value +2025-11-14T12:56:00.742Z,-0.58778524 +2025-11-14T12:56:01.741Z,-2.4492937e-16 +2025-11-14T12:56:02.742Z,0.58778524 +2025-11-14T12:56:03.742Z,0.95105654 +2025-11-14T12:56:04.742Z,0.95105654 +2025-11-14T12:56:07.34Z,0.58778524 +2025-11-14T12:56:08.34Z,1.2246469e-16 +2025-11-14T12:56:09.34Z,-0.58778524 +2025-11-14T12:56:10.34Z,-0.95105654 +2025-11-14T12:56:11.339Z,-0.95105654 +2025-11-14T12:56:12.339Z,-0.58778524 +2025-11-14T12:56:13.34Z,-2.4492937e-16 +2025-11-14T12:56:14.34Z,0.58778524 +2025-11-14T12:56:15.34Z,0.95105654 +2025-11-14T12:56:16.339Z,0.95105654 +2025-11-14T12:56:17.34Z,0.58778524 +2025-11-14T12:56:18.339Z,1.2246469e-16 +2025-11-14T12:56:19.34Z,-0.58778524 +2025-11-14T12:56:20.34Z,-0.95105654 +2025-11-14T12:56:21.34Z,-0.95105654 +2025-11-14T12:56:22.339Z,-0.58778524 +2025-11-14T12:56:23.34Z,-2.4492937e-16 +2025-11-14T12:56:24.34Z,0.58778524 +2025-11-14T12:56:25.339Z,0.95105654 +2025-11-14T12:56:26.34Z,0.95105654 +2025-11-14T12:56:27.34Z,0.58778524 +2025-11-14T12:56:28.34Z,1.2246469e-16 +2025-11-14T12:56:29.34Z,-0.58778524 +2025-11-14T12:56:30.34Z,-0.95105654 +2025-11-14T12:56:31.34Z,-0.95105654 +2025-11-14T12:56:32.34Z,-0.58778524 +2025-11-14T12:56:33.34Z,-2.4492937e-16 +2025-11-14T12:56:34.34Z,0.58778524 +2025-11-14T12:56:35.34Z,0.95105654 +2025-11-14T12:56:36.339Z,0.95105654 +2025-11-14T12:56:37.339Z,0.58778524 +2025-11-14T12:56:38.339Z,1.2246469e-16 +2025-11-14T12:56:40.935Z,-0.58778524 +2025-11-14T12:56:41.934Z,-0.95105654 +2025-11-14T12:56:42.935Z,-0.95105654 +2025-11-14T12:56:43.935Z,-0.58778524 +2025-11-14T12:56:44.935Z,-2.4492937e-16 +2025-11-14T12:56:45.935Z,0.58778524 +2025-11-14T12:56:46.934Z,0.95105654 +2025-11-14T12:56:47.935Z,0.95105654 +2025-11-14T12:56:48.935Z,0.58778524 +2025-11-14T12:56:49.934Z,1.2246469e-16 +2025-11-14T12:56:50.935Z,-0.58778524 +2025-11-14T12:56:51.934Z,-0.95105654 +2025-11-14T12:56:52.934Z,-0.95105654 +2025-11-14T12:56:53.934Z,-0.58778524 +2025-11-14T12:56:54.934Z,-2.4492937e-16 +2025-11-14T12:56:55.935Z,0.58778524 +2025-11-14T12:56:56.935Z,0.95105654 +2025-11-14T12:56:57.935Z,0.95105654 +2025-11-14T12:56:58.936Z,0.58778524 +2025-11-14T12:56:59.935Z,1.2246469e-16 + + diff --git a/tests/atest/testdata/example_08.csv b/tests/atest/testdata/example_08.csv new file mode 100644 index 00000000..d8c71e49 --- /dev/null +++ b/tests/atest/testdata/example_08.csv @@ -0,0 +1,59 @@ +2025-11-14T12:56:00.742Z,-0.58778524 +2025-11-14T12:56:01.741Z,-2.4492937e-16 +2025-11-14T12:56:02.742Z,0.58778524 +2025-11-14T12:56:03.742Z,0.95105654 +2025-11-14T12:56:04.742Z,0.95105654 +2025-11-14T12:56:07.34Z,0.58778524 +2025-11-14T12:56:08.34Z,1.2246469e-16 +2025-11-14T12:56:09.34Z,-0.58778524 +2025-11-14T12:56:10.34Z,-0.95105654 +2025-11-14T12:56:11.339Z,-0.95105654 +2025-11-14T12:56:12.339Z,-0.58778524 +2025-11-14T12:56:13.34Z,-2.4492937e-16 +2025-11-14T12:56:14.34Z,0.58778524 +2025-11-14T12:56:15.34Z,0.95105654 +2025-11-14T12:56:16.339Z,0.95105654 +2025-11-14T12:56:17.34Z,0.58778524 +2025-11-14T12:56:18.339Z,1.2246469e-16 +2025-11-14T12:56:19.34Z,-0.58778524 +2025-11-14T12:56:20.34Z,-0.95105654 +2025-11-14T12:56:21.34Z,-0.95105654 +2025-11-14T12:56:22.339Z,-0.58778524 +2025-11-14T12:56:23.34Z,-2.4492937e-16 +2025-11-14T12:56:24.34Z,0.58778524 +2025-11-14T12:56:25.339Z,0.95105654 +2025-11-14T12:56:26.34Z,0.95105654 +2025-11-14T12:56:27.34Z,0.58778524 +2025-11-14T12:56:28.34Z,1.2246469e-16 +2025-11-14T12:56:29.34Z,-0.58778524 +2025-11-14T12:56:30.34Z,-0.95105654 +2025-11-14T12:56:31.34Z,-0.95105654 +2025-11-14T12:56:32.34Z,-0.58778524 +2025-11-14T12:56:33.34Z,-2.4492937e-16 +2025-11-14T12:56:34.34Z,0.58778524 +2025-11-14T12:56:35.34Z,0.95105654 +2025-11-14T12:56:36.339Z,0.95105654 +2025-11-14T12:56:37.339Z,0.58778524 +2025-11-14T12:56:38.339Z,1.2246469e-16 +2025-11-14T12:56:40.935Z,-0.58778524 +2025-11-14T12:56:41.934Z,-0.95105654 +2025-11-14T12:56:42.935Z,-0.95105654 +2025-11-14T12:56:43.935Z,-0.58778524 +2025-11-14T12:56:44.935Z,-2.4492937e-16 +2025-11-14T12:56:45.935Z,0.58778524 +2025-11-14T12:56:46.934Z,0.95105654 +2025-11-14T12:56:47.935Z,0.95105654 +2025-11-14T12:56:48.935Z,0.58778524 +2025-11-14T12:56:49.934Z,1.2246469e-16 +2025-11-14T12:56:50.935Z,-0.58778524 +2025-11-14T12:56:51.934Z,-0.95105654 +2025-11-14T12:56:52.934Z,-0.95105654 +2025-11-14T12:56:53.934Z,-0.58778524 +2025-11-14T12:56:54.934Z,-2.4492937e-16 +2025-11-14T12:56:55.935Z,0.58778524 +2025-11-14T12:56:56.935Z,0.95105654 +2025-11-14T12:56:57.935Z,0.95105654 +2025-11-14T12:56:58.936Z,0.58778524 +2025-11-14T12:56:59.935Z,1.2246469e-16 + +