Can you always show table columns?

Currently I have a dynamic name query setup to look through multiple tables on the fly and make edits.

I have noticed when a table has no rows of data the table will remain empty even if there are columns in the table.

Is there a way to make the columns always visible even if there are no rows of data?

Edit: Actually I figured out a solution to my own question lol.But it was made better with the help of PGriffith.

if value.rowCount == 0:
		column_names = list(value.columnNames)  # Ensure columnNames is a list of strings
		return system.dataset.toDataSet(column_names, [[None] * value.columnCount])
	return value

Pointless golf:

if value.rowCount == 0:
    return system.dataset.toDataSet(
        value.columnNames,
        [[None] * value.columnCount]
    )

return value

That wasn't working for me, i had to change it slightly. I was getting a coerced error. Here's what I ended up with after your help! Thanks :grinning_face::

if value.rowCount == 0:
		column_names = list(value.columnNames)
		return system.dataset.toDataSet(column_names, [[None] * value.columnCount])
	return value
2 Likes