M. Edward (Ed) Borasky wrote > Michael Linfield wrote: > > If i had a huge CSV file, and i wanted to pull out say all the lines > > that contained the word "Blah1" and throw it in a temporary file what > > would be the best approached. My thoughts were to use > > > require 'rubygems' > > require 'ruport' > > require 'ruport/util' > > > t=Ruport::Data:Table.load("filename.csv") > > t.grep(/Blah1/) > > > ### this sadly only returned an output of => [] > > > any ideas? > > > Thanks! > > OK ... first of all, define "huge" and what are your > restrictions? Let me assume the worst case just to get > started -- more than 256 columns and more than 65536 rows > and you're on Windows. :) > > Seriously, though, if this is a *recurring* use case rather > than a one-shot "somebody gave me this *$&%^# file and wants > an answer by 5 PM tonight!" use case, I'd load it into a > database (assuming your database doesn't have a column count > limitation larger than the column count in your file, that > is) and then hook up to it with DBI. But if it's a one-shot > deal and you've got a command line handy (Linux, MacOS, BSD > or Cygwin) Windoze has a command-line. > just do "grep blah1 huge-file.csv > > temp-file.csv". Bonus points for being able to write that in > Ruby and get it debugged before someone who's been doing > command-line for years types that one-liner in. :) Chris Carter has already done it. Have you ever posted Ruby code here?