Guest2  
                (Guest)
               
                 
              
                  
                    22 July 2008 18:09
                   
                   
              1 
               
             
            
              Hi all,
I just try fastercsv and it works fine.
I use the codes below to print out the first columns of the first ten 
rows. And it is OK.  Question1) Is this the Ruby way to do that? 
Question 2)what if I want to print out the first columns of row  20-30?
Thank you very much,
Li
··· 
#### 
i=1 
  FasterCSV.foreach('test.csv','rb') do |row| 
         puts row[0] 
         break  if i==10 
         i+=1 
  end 
#### 
-- 
Posted via http://www.ruby-forum.com/ .
 
             
            
               
               
               
            
            
           
          
            
            
              
Hi all,
 
Hello.
I just try fastercsv and it works fine.
 
Great.
I use the codes below to print out the first columns of the first ten 
rows. And it is OK.  Question1) Is this the Ruby way to do that?
 
It's definitely one possible way.  You could also use:
   FCSV.open('test.csv') do |csv| 
     csv.each do |row| 
       puts row.first 
       break if csv.lineno >= 10 
     end 
   end
Question 2)what if I want to print out the first columns of row  20-30?
 
   FCSV.open('test.csv') do |csv| 
     csv.each do |row| 
       puts row.first if csv.lineno >= 20 
       break if csv.lineno >= 30 
     end 
   end
Hope that gives you some fresh ideas.
James Edward Gray II
··· 
On Jul 22, 2008, at 1:09 PM, Li Chen wrote:
 
             
            
               
               
               
            
            
           
          
            
              
                Guest2  
                (Guest)
               
              
                  
                    22 July 2008 18:33
                   
                   
              3 
               
             
            
              Hi James,
Thank you very much.  But where can I find description about method 
row.first and csv.lineno  in the document?
Li
··· 
-- 
Posted via http://www.ruby-forum.com/ .
 
             
            
               
               
               
            
            
           
          
            
            
              http://www.ruby-doc.org/core/classes/Array.html#M000275 
http://fastercsv.rubyforge.org/classes/FasterCSV.html   (look in the Attributes section)
James Edward Gray II
··· 
On Jul 22, 2008, at 1:33 PM, Li Chen wrote:
Thank you very much.  But where can I find description about method 
row.first and csv.lineno  in the document?
 
 
             
            
               
               
               
            
            
           
          
            
              
                Guest2  
                (Guest)
               
              
                  
                    22 July 2008 19:08
                   
                   
              5 
               
             
            
              James Gray wrote:
class Array - RDoc Documentation 
http://fastercsv.rubyforge.org/classes/FasterCSV.html   (look in the 
Attributes section)
James Edward Gray II
 
Thank you very much. They are really sweet.
Li
··· 
-- 
Posted via http://www.ruby-forum.com/\ .