On 16 Aug 2007, at 13:29, Michael L. wrote:
data from, then at the end of the program delete Blah1.csv ?
Sure, use tempfile, but I think botp has shown why you don’t really
need the temporary file (unless there’s part of this problem I’m not
understanding):
irb(main):001:0> puts File.readlines(‘filename.csv’)
this, is , a , test, foo
this, is , a , test, bar
this, is , a , test, Blah1
this, is , a , test, bar
this, Blah, is , a , test
this, is , a , Blah, test
=> nil
irb(main):002:0> puts File.readlines(‘filename.csv’).grep(/Blah1/)
this, is , a , test, Blah1
=> nil
irb(main):003:0> require ‘tempfile’
=> true
irb(main):004:0> tf = Tempfile.new(‘csv’)
=> #<File:/tmp/csv.1339.0>
irb(main):005:0> tf.puts File.readlines(‘filename.csv’).grep(/Blah1/)
=> nil
irb(main):006:0> tf.close
=> nil
irb(main):007:0> tf.open
=> #<File:/tmp/csv.1339.0>
irb(main):008:0> puts tf.gets
this, is , a , test, Blah1
=> nil
Alex G.
Bioinformatics Center
Kyoto University