Hello again, Paul

I found another problem.  I am sorry not to include this in the previous post.

As you set "opf" inside the each_line loop, "opt.puts line"(where I add a mark)
won't work when both contents of ifs are not processed, i.e. the opf
is not defined
inside the loop.

To solve this problem, add definition of opf ("opf = nil") before the loop.


Look at next examples

-- code 1
flag = false

1.upto(3) do |i|
  unless flag
    bad_var = 1000
    flag = true
  end
  puts "#{i}, #{bad_var.nil?}"
end

-- result 1
1, false
2, true
3, true

-- code 2
flag = false

bad_var = nil # << bad_var is defined here
1.upto(3) do |i|
  unless flag
    bad_var = 1000
    flag = true
  end
  puts "#{i}, #{bad_var.nil?}"
end

-- result 2
1, false
2, false
3, false


On Fri, Apr 1, 2011 at 4:31 PM, Paul Joyce <pjoyce / whatsthis.ie> wrote:
>
> #puts template
> ipf = File.new("All-Contracts-29-Mar-11.csv","r")
>  ¨Âðæ®åáãèßìéîå üìéîåü
>  ¨Âåøéæ ìéîå®íáôã訯ޤ¯©
>  ¨Âáôìéîå®óðìéô¨¢¬¢>  ¨Âãõòò ½½ ¢ø ¨Âîéôéáìéú>  ¨Âõô¢ÉîéôéáìéúäáôáÛ°>  ¨Âðæ Æéìå®îå÷¨äáôáÛ°Ý §­æååäåò­ãõóôïíåò®ãóö§¬¢ò«¢©
>  ¨Âðæ®ðõôãïìèåá¼­­­­­  ¨ÂÅÒ>  ¨Âîä
>  ¨Âãõòò ¡½ äáôáÛ°áîãõòò ¡½ ¢ø> puts "New File . . . " + data[0]
> opf.close
> opf = File.new(data[0] + "-feeder-customer.csv","r+")
> opf.puts colhead
>  ¨Âîä
>  ¨Âðæ®ðõôìéîå ££ ¼­Ôèéó ïããõòó îéãìáóåòòï>  ¨ÂõòäáôáÛ°>  ¨Â
> ipf.close;
> opf.close;
>
> puts 'DONE.'
>

-- 
Haruka YAGNI