Re: sorting data from a file

2012-12-04 Thread Alan Forrester
On Wed, Nov 28, 2012 at 2:47 PM, Ismail M. wrote: > I haven't done any thing yet.. i just didn't know where to start. > btw those numbers are not arrays. its the content of the file. Documentation for Ruby is here http://www.ruby-doc.org/core-1.9.3/ You're going to need to look at things like "

Re: sorting data from a file

2012-12-04 Thread Alan Forrester
On Wed, Nov 28, 2012 at 3:36 PM, Ismail M. wrote: > of course I see your point Jan E. > > I opened/read the file and displayed in on ruby command promt. > > then i thought of a way to sort the data in the file. > > > l = [1,2,3,3,1,6,5] > > smallest = l.sort.first 4 > > => [1,1,2,3] > > however ap

Re: sorting data from a file

2012-12-04 Thread Alan Forrester
On 28 Nov 2012, at 19:15, 7stud -- wrote: > Alan Forrester wrote in post #1086915: >> >> In your script, read the file into an array using >> myarray = IO.readlines("myfile.txt") >> > > Why would you suggest that? What's the matter with the method: > > IO.foreach(fname) {|line| #code here}

Re: sorting data from a file

2012-11-29 Thread Иван Бишевац
If you want to go through all rows then you type: @csv.each do |row| # do something with row end -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this

Re: sorting data from a file

2012-11-29 Thread Иван Бишевац
It's beginner question. My advice is that you go through some beginners tutorial about Ruby. After that you will know to implement it. Here is your starting code: require 'csv' class ParseCSV def initialize @csv = CSV.read "data.csv" end def test @csv[0] # it's first row end end pc = ParseCSV