how to read out the column labels of DataTables #6479
Replies: 2 comments
-
|
Ok, found a solution, which is a bit complex, I think: column_names = []
for _i in range(len(self.get_row_at(0))):
_coord = Coordinate(row=0, column=_i)
_row_key, _column_key = self.coordinate_to_cell_key(_coord)
column_names.append(self.columns[_column_key].label)where |
Beta Was this translation helpful? Give feedback.
0 replies
-
[column.label for column in table.ordered_columns] |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nnako
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
is there a way to read out the column labels of an existing DataTable? The labels can be set e.g. via
<DataTable>.add_column()or<DataTable>.add_columns(), but reading them out does not seem obvious to me. The documentation mentions an attribute<DataTable>.columns, but it just says it would be adictaccessed by theColumnKeyand providing aColumnwith no further explanation than mentioning "metadata".Using
<DataTable>.get_row_at(0)returns the 1st data row, not the respective column names.As it doesn't seems possible to set breakpoints within a
textualapplication, single-step debugging and probing does not seem to be possible.Is there any help on
- the particular question about DataTable column label determination?
Or some hints about how to debug more easily?
Beta Was this translation helpful? Give feedback.
All reactions