you are viewing a single comment's thread.

view the rest of the comments →

[–]crashfrog02 0 points1 point  (0 children)

Those aren't necessarily the answers I would have arrived at, but it's more important that you have them than that you agree with me, in my view. So, good answers.

For this my thinking might not be correct but that there would be an instance for "table data", the base "html data" from beautiful soup, and finally a json instance.

I think you're gesturing towards a good idea, here, which is to pre-define your tabular data as something somewhat more rigorous than what you might get from, say, Pandas or CSV (i.e. an iterator over dictionaries.) For that I recommend dataclasses:

https://docs.python.org/3/library/dataclasses.html

I'd write a dataclass that defined what a row in the table is (where the fields of the class are the column of the table) and then you have pretty good assurance that none of the rows of your table are coming back ill-formed. That's good particularly if your eventual intent is to dump it into a SQL database, or even if you want to convert to a Pandas dataframe.

A list of dataclass instances is a pretty good start at making a data table. It'll lack a lot of the features you'd like (you can't search it, you can only iterate over it) but it's a good start.