pages 558-559, in CSV
% ruby -w sl_csv/sample_0.rb
sl_csv/sample_0.rb:9:in `chdir': No such file or directory @ dir_s_chdir - code/sl_csv (Errno::ENOENT)
from sl_csv/sample_0.rb:9:in `<main>'
The downloaded code has a chdir
before require
which does not appear in the book :
Dir.chdir("code/sl_csv")
require "csv"
CSV.foreach("csvfile.csv") do |row|
...
Until now all code had to be run with code
as the current directory, so code
in "code/sl_csv"
is wrong. The statement must be :
Dir.chdir("sl_csv")
or without Dir.chdir
:
CSV.foreach("sl_csv/csvfile.csv") do |row|
Same problem with sample_1.rb
and sample_3.rb
.