very new to python so attempting to wrap my head around multi dimensional arrays. I read the existing posts and most of them deal with multi dimensional arrays given dimensions. In my case, I do not have dimensions for the total number of rows possible. A file is being processed, which is CSV and has 7 columns, but each line, depending on meeting or failing a criteria is accordingly drafted into an array. Essentially each line has 7 columns, but the number of rows cannot be predicted. The line is being treated as a list.
My aim is to create a multidimensional array of eligible lines and then be able to access values in the array. how can I do this?
essentially, how do I tackle creating a 2D list:
list_2d = [[foo for i in range(m)] for j in range(n)]
The above creates an mxn sized list but in my case, I know only n (columns) and not m(rows)
Nest lists in lists you don’t need to predefine the length of a list to use it and you can append on to it. Want another dimension simply append another list to the inner most list.
and to use them easily just look at Nested List Comprehensions