Working with 2D lists of data

Say that you have a table of data stored in a 2D list. You may want to run through the data and access the values along with their property & entity labels.

Say you have a table like this:

Household IDCatsChildrenGarbage Cans

House A

3

0

4

House B

1

2

5

House C

1

0

1

Here we have a table of data that is describing three households and their number of cats, children, and garbage cans. Note the structure is pretty specific. The upper left cell is often left empty or in an odd way because we don't think to label the ID columms as such. Before you get into this, you should think about how to adjust that.

One of the keys will be to get the headers row cleanly sliced off of data rows. If you treat the ID as a regular property it can be easier. What does get weird is if the data types are different.

This is why it can be best to treat all data in such a list as strings until the point of calculations. Your instincts will be to get them stored as how they should be (integers) as soon as possible, but waiting on that gives you the benefit of being able to treat everything as the same data type until you are good and ready to do the processing.

So once you hack off the headers, you are left with rows of data.

Last updated