I am trying to split a row from a CSV file into an array. I can print out all the contents from the CSV file to the console no problem, like this:
CSV.foreach('so1.csv', :headers => true, :col_sep => "\t", :skip_blanks => true) do |row|
id, name = row[0], row[1]
puts id, name
end
However, when I try to split name i.e. row[1] into an names array, I get a undefined method 'split' for nil:NilClass (NoMethodError) message:
CSV.foreach('so1.csv', :headers => true, :col_sep => "\t", :skip_blanks => true) do |row|
id, name = row[0], row[1]
unless (id =~ /#/)
names = name.split
end
I have also tried name.split("\n") and name.split("\t") to no avail.
For clarity, a screenshot of the CSV file:

Could anybody shed any light on what is going wrong here? It would be great - thanks.