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.new pc.test As you see it's easier to process your data by csv class, since it's in comma separaterd values format. In constructor you initialize @csv variable which is 2 dimensional array. You acces it through indexes. For example to get 1st cell, then you type @csv[0][0]. You get first row by @csv[0]. If you want to go through all rows then you type: @csv.each do |row| 2012/11/28 Jan E. <[email protected]> > You can argue all day long about which solution is easier to understand > and better for a beginner. But personally, I'm more interested in which > methods *he* knows. If he knows File.readlines, that's fine. Then we can > use it. If he knows File.foreach, that's fine, too. > > I know Ruby programmers love endless discussions about the best > solution. But it would be great if maybe this time you could not do that > and just help. > > > @ Ismail: > > Please write down everything that you currently have (ideas, code, > whatever). Your code snippet for the smallest number is already useful. > You'll be able to use that later. > > -- > Posted via http://www.ruby-forum.com/. > > -- 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 group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
