I have a file that I am reading that follows the following format:
12345,500,500
23456,100,150
34567,99,109
What I'm trying to do is read up until the first comma of the file and then map them into an array.
test = File.read('results.txt').split(',')[0]
p test
=> "12345"
would return me back the first value before the comma but I want to put all of them into an array
test = File.read('results.txt').split(',')[0].map(&:strip)
I have tried the following above and other similar permutations but unfortunately it's not quite the right it seems.
my desired result is to have an array of the following
[12345,23456,34567]
"12345"). Later you say you want an array of three integers. Which is it? In any event, if you want an array containing the first part of every line, that obviously gives you the first part of the first line, so I don't understand why the question even mentions the first line.