I'm trying to achieve an array that is a collection of the first element of each row achieved by reading a CSV file.
I have the following:
ids = []
CSV.foreach(filename) do |row|
ids << row[0]
end
ids
Is there any way to write this in one line? Or neater than that?
CSV.foreach(filename).map(&:first)should work.