I have a CSV where the first column gives the weekday. But the problem is that I need to use the CSV in MATLAB, which does not allow string values. So, I want to convert the Sunday to 7, ..., Monday to 1 in the CSV.
But I can't seem to find a way to do that in Ruby. And I can't open the excel manually to do it either because the file size is huge. Specifically, I'm having problem in figuring out the syntax of how to access and point to the specific column I want in Ruby. For example, if the file would have loaded in MATLAB, and if I was still required to convert the weekdays into numbers for some reason, I would have written a simple code like this:
for i=1:length(Columns(:,1))
if Columns(i,1)=='sunday'
Columns(i,1)=7
elseif Columns(i,1)=='saturday'
Columns(i,1)=6
elseif Columns(i,1)=='friday'
Columns(i,1)=5
elseif Columns(i,1)=='thursday'
Columns(i,1)=4
elseif Columns(i,1)=='wednesday'
Columns(i,1)=3
elseif Columns(i,1)=='tuesday'
Columns(i,1)=2
elseif Columns(i,1)=='monday'
Columns(i,1)=1
end
end
So, I am having problem in figuring out the Ruby equivalent of this statement:
for i=1:length(Columns(:,1))
Any help is appreciated. Thanks.