开发者

Opening/using a table up in Ruby

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜