From: "lrlebron@..." Date: 2007-12-29T06:35:12+09:00 Subject: Re: How to jump over the first line in a file? (newbie) On Dec 28, 3:01 pm, Joe wrote: > I don't see File.open here:http://ruby-doc.org/core/classes/File.html > Am I looking in the wrong place? > > Also, how do you find out about globals like $. ? > > Joe > > On Dec 28, 2007 3:20 PM, lrleb...@gmail.com wrote: > > > > > On Dec 28, 12:49 pm, Mark Toth wrote: > > > I have this code: > > > > file = "filename.txt" > > > File.open(file) do |sFile| > > > while line = sFile.gets > > > row = line.split("\t") > > > a_product = Product.new( > > > :sku => row[0] , > > > :name => row[1] , > > > :price => row[2] , > > > a_product.save > > > end > > > end > > > > What if I want to jump over the first line of the file so it won´t be > > > imported? > > > > Thank you, > > > > Mark > > > -- > > > Posted viahttp://www.ruby-forum.com/. > > > The $. variable holds the line number so you could do something like > > this: > > > File.open("filename.txt") do |aFile| > > aFile.each_line do |line| > > if $. > 1 > > #processs data here > > > end > > end > > end > > > Luis Open is a kernel method http://ruby-doc.org/core/classes/Kernel.html#M005990 For variables like $. see Programming Ruby 2ed Chapter 22 (page 334 for $.) Luis