This is a concept question regarding data structures in ruby. I would like to iterate through rows of a spreadsheet. There are gems to do this, but I want to understand the difference between allocating a row as a hash of arrays (where the first column is the key and the rest of them the value as array) and just having a row as an array. Does it matter?
-
It is not clear what you mean by "a row as a hash of arrays (where the first column is the key and the rest of them the value as array)".sawa– sawa2015-09-06 10:11:29 +00:00Commented Sep 6, 2015 at 10:11
-
Your title is also confusing. Do you mean to represent "the spreadsheet with array of arrays"?sawa– sawa2015-09-06 10:15:18 +00:00Commented Sep 6, 2015 at 10:15
Add a comment
|
1 Answer
It really depends on what you want to do with the result.
Representing a spreadsheet as an array of arrays means determining the meaning of each cell positionally, which is more complex than using a hash. But if you don't care about the meaning and just wanted to write the data to a csv for example, then an array of arrays would be suitable.
So think about what you actually want to do with the data in the future.