tags:

views:

34

answers:

1

Hello,

I have a simple tab-separated text file that I want Ruby to read every value in the second column and write out a text file with each table value and another number. I was wondering how might I go about doing this (probably using some kind of loop).

Thanks

+2  A: 
File.open("output.txt", "w") do |output_file|
  File.open("input.txt") do |input_file|
    input_file.each_line do |line|
      values = line.split("\t")
      output_file.puts "#{values[1]} anothervalue"
    end
  end
end
duncan
Beautiful Duncan, thank all of you all so much. Lifesavers!
Bobby