Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19228

Re: Splitting a file from specific column content

Subject Re: Splitting a file from specific column content
From Roy Smith <roy@panix.com>
Date 2012-01-22 14:26 -0500
References <e1f0636a-195c-4fbb-931a-4d619d5f0d18@g27g2000yqa.googlegroups.com> <roy-125359.09450822012012@news.panix.com> <4F1C628F.1000105@tim.thechases.com>
Newsgroups comp.lang.python
Message-ID <mailman.4933.1327260402.27778.python-list@python.org> (permalink)

Show all headers | View raw


I stand humbled.

On Jan 22, 2012, at 2:25 PM, Tim Chase wrote:

> On 01/22/12 08:45, Roy Smith wrote:
>> I would do this with standard unix tools:
>> 
>> grep '^[012]' input.txt>  first-three-seconds.txt
>> grep '^[34]' input.txt>  next-two-seconds.txt
>> grep '^[567]' input.txt>  next-three-seconds.txt
>> 
>> Sure, it makes three passes over the data, but for 20 MB of data, you
>> could have the whole job done in less time than it took me to type this.
> 
> 
> If you wanted to do it in one pass using standard unix tools, you can use:
> 
> sed -n -e'/^[0-2]/w first-three.txt' -e'/^[34]/w next-two.txt' -e'/^[5-7]/w next-three.txt'
> 
> -tkc
> 
> 
> 


--
Roy Smith
roy@panix.com


Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Splitting a file from specific column content Yigit Turgut <y.turgut@gmail.com> - 2012-01-22 06:32 -0800
  Re: Splitting a file from specific column content Roy Smith <roy@panix.com> - 2012-01-22 09:45 -0500
    Re: Splitting a file from specific column content Roy Smith <roy@panix.com> - 2012-01-22 14:26 -0500
    Re: Splitting a file from specific column content Tim Chase <python.list@tim.thechases.com> - 2012-01-22 13:34 -0600
    Re: Splitting a file from specific column content Roy Smith <roy@panix.com> - 2012-01-22 14:37 -0500
      Re: Splitting a file from specific column content Yigit Turgut <y.turgut@gmail.com> - 2012-01-22 12:16 -0800
  Re: Splitting a file from specific column content MRAB <python@mrabarnett.plus.com> - 2012-01-22 15:19 +0000
  Re: Splitting a file from specific column content Arnaud Delobelle <arnodel@gmail.com> - 2012-01-22 15:39 +0000
    Re: Splitting a file from specific column content Yigit Turgut <y.turgut@gmail.com> - 2012-01-22 08:17 -0800
      Re: Splitting a file from specific column content MRAB <python@mrabarnett.plus.com> - 2012-01-22 16:56 +0000
        Re: Splitting a file from specific column content Yigit Turgut <y.turgut@gmail.com> - 2012-01-22 09:47 -0800
    Re: Splitting a file from specific column content Eelco <hoogendoorn.eelco@gmail.com> - 2012-01-22 12:43 -0800
  Re: Splitting a file from specific column content MRAB <python@mrabarnett.plus.com> - 2012-01-22 16:09 +0000
  Re: Splitting a file from specific column content Arnaud Delobelle <arnodel@gmail.com> - 2012-01-22 19:58 +0000
  Re: Splitting a file from specific column content MRAB <python@mrabarnett.plus.com> - 2012-01-22 20:55 +0000

csiph-web