From: Saji Hameed Date: 2012-10-29T17:12:20+09:00 Subject: Re: csv.rb:1342:in `initialize': No such file or directory > I must be making a very stupid mistake but the following piece of code > gives an error > dir = "~/Dropbox/Ruby/FlightLuggage/" I think you should replace ~ with ENV['HOME'] ! saji On Mon, Oct 29, 2012 at 5:05 PM, Soichi Ishida wrote: > ruby-1.9.3-p286 > > > I must be making a very stupid mistake but the following piece of code > gives an error > > /Users/soichi/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/csv.rb:1342:in > `initialize': No such file or directory - > ~/Dropbox/Ruby/FlightLuggage/airport.csv (Errno::ENOENT) > from > /Users/soichi/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/csv.rb:1342:in > `open' > from > /Users/soichi/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/csv.rb:1342:in > `open' > from csv_manipulate.v1.rb:11:in `
' > > > # the code is > require 'csv' > > dir = "~/Dropbox/Ruby/FlightLuggage/" > file = "airport.csv" > filename = dir + file > > csv_line_read = CSV.open(filename) > header = csv_line_read.shift > > csv_line_read.each do |row| > p row > end > > > Could anyone point out the mistake I am making here? I have > double-checked the file directory. > > soichi > > -- > Posted via http://www.ruby-forum.com/. > -- Saji N Hameed, ARC-ENV, Center for Advanced Information Science and Technology, University of Aizu, Tsuruga, Ikki-machi, Aizuwakamatsu-shi, Fukushima 965-8580, Japan Tel: +81242 37-2736 Fax:+81242 37-2760 email: saji@u-aizu.ac.jp url: http://www.u-aizu.ac.jp bib: http://www.researcherid.com/rid/B-9188-2009