Delete empty cells in Data Table

Hi, @david.modiano1.

Sorry to say, in a database table, every row has exactly the same columns. That really is why they are called tables. They had that structure when they were invented around 50 years ago. You use a table when you want every row to have the same structure.

In a row, a column may have no data (its value is NULL, in SQL terms, or None, in Python terms). But the column will always be there.

It seems you have a contradiction before you. You want something that conforms to the shape of a CSV file’s data – which is a table – but you also want something that doesn’t.

You can’t (trivially) get both in the same data structure. But you can write code to translate between two different structures, and use each structure where it fits the best.

EDIT:
Anvil provides a SimpleObject column type, which can help in cases like these. For values that are guaranteed to be in every row, use “normal” columns. For the remaining values, collect them into a list or dict, and save the resulting object in the SimpleObject column. This way, you can get something of both worlds in the same data structure.

2 Likes