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 wond开发者_JS百科ering how might I go about doing this (probably using some kind of loop).
Thanks
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
精彩评论