Re: [Rails] How to edit each line of a file in ruby, without using a temp file

2012-10-02 Thread Walter Lee Davis
On Oct 2, 2012, at 12:00 AM, Nila wrote: > Hi, > > Is there a way to edit each line in a file, without involving 2 files? Say, > the original file has, > > test01 > test02 > test03 > > I want to edit it like > test01,a > test02,a > test03,a > > Tried something like this, but it replaces some

Re: [Rails] How to edit each line of a file in ruby, without using a temp file

2012-10-02 Thread Colin Law
On 2 October 2012 05:00, Nila wrote: > Hi, > > Is there a way to edit each line in a file, without involving 2 files? Say, > the original file has, > > test01 > test02 > test03 > > I want to edit it like > test01,a > test02,a > test03,a > > Tried something like this, but it replaces some of the ch

[Rails] How to edit each line of a file in ruby, without using a temp file

2012-10-01 Thread Nila
Hi, Is there a way to edit each line in a file, without involving 2 files? Say, the original file has, test01 test02 test03 I want to edit it like test01,a test02,a test03,a Tried something like this, but it replaces some of the characters. File.open('mytest.csv', 'r+') do |file| file.e