magawake at gmail.com
Thu Apr 8 14:21:10 CEST 2010
Oh, thats nice to know!
But I use the CSV module with gzip module. Is it still possible to do
it with the subprocess?
On Thu, Apr 8, 2010 at 7:31 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Mag Gam, 08.04.2010 13:21:
>> I am in the process of reading a zipped file which is about 6gb.
>> I would like to know if there is a command similar to grep in python
>> because I would like to emulate, -A -B option of GNU grep.
>> Lets say I have this,
>> if I do grep -A2 -B2 "CC"
>> I get 2 lines before and 2 lines after "C"
>> Is there an easy way to do this in python?
> Sure, just use a sliding window.
> However, for a 6BG file, you won't really like the performance. It's
> basically impossible to beat the speed of (f)grep.
> I'd use the subprocess module to run zfgrep over the file and parse the
> output in Python.
More information about the Python-list