Skip to content

Commit 6902b0b

Browse files
author
Christel Gérardin
committed
Tables pipe modified with black
1 parent 07871ed commit 6902b0b

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

edsnlp/pipelines/misc/tables/tables.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def divisors(n):
153153
result.add(n // i)
154154
return sorted(list(result))
155155

156+
# Do not count the column names when splitting the table
156157
if self.col_names:
157158
n_rows = len(processed_table) - 1
158159
else:
@@ -170,17 +171,26 @@ def divisors(n):
170171
== row_len
171172
for i in range(n_rows // n_rows_to_merge)
172173
):
173-
processed_table = [
174-
[
175-
cell
176-
for subrow in processed_table[
177-
i * n_rows_to_merge : (i + 1) * n_rows_to_merge
178-
]
179-
for cell in subrow
180-
]
181-
for i in range(n_rows // n_rows_to_merge)
182-
]
183-
tables_list.append(processed_table)
174+
new_table = []
175+
for i in range(n_rows // n_rows_to_merge):
176+
# Init new_row with the first subrow
177+
new_row = processed_table[i * n_rows_to_merge]
178+
for subrow in processed_table[
179+
i * n_rows_to_merge + 1 : (i + 1) * n_rows_to_merge
180+
]:
181+
new_row = (
182+
new_row[:-1]
183+
+ [
184+
table[
185+
new_row[-1].start
186+
- table.start : subrow[0].end
187+
- table.start
188+
]
189+
]
190+
+ subrow[1:]
191+
)
192+
new_table.append(new_row)
193+
tables_list.append(new_table)
184194
break
185195
continue
186196
else:

0 commit comments

Comments
 (0)