I figured already out how to work with ar_of_ar, but can’t select multiple elements of only the second column.
temp_ary=CSV.read(file, {col_sep->";"})
the mounted file has the structure:
[Date, value]
june6;1200.02
jul6;500.04
dec06; 3400.07
after having imported, I want to count the values which are greater than 1000. However, the normal adressing I’m used to does not work, thus selecting values 1..3 of column2:
temp_ary[2..3][1]
only returns the first value?
I’m not sure whatever values I can expect, but I want to count occurring nil, null, 0, space values and so on, which are no real numbers. How can I efficiently do that?
You could do something like this:
You can pass a “block” to the count method to specify a predicate to count on.
See http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-count
Also you might not be interested by the method “csv” and so on. The hard work is done by the count method.
EDIT: If you just wanted to select certain values of you CSV file. I suggest taking a look at the method “values_at”: http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-values_at