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


Groups > comp.lang.python > #32005

Re: Split single file into multiple files based on patterns

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'skip:/ 10': 0.07; 'subject:file': 0.07; 'alain': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:files': 0.09; 'subject:into': 0.09; '303': 0.16; '3465': 0.16; 'awk': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:based': 0.16; 'wrote:': 0.17; 'split': 0.23; 'feature': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'writes:': 0.29; 'this.': 0.29; 'file': 0.32; 'from:addr:yahoo.co.uk': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'text': 0.34; 'received:org': 0.36; 'but': 0.36; 'being': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'beats': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Split single file into multiple files based on patterns
Date Wed, 24 Oct 2012 07:13:24 +0100
References <9ae3b43a-5c69-4232-a1cf-e2dd0c4ee2ca@googlegroups.com> <87wqyga0cr.fsf@dpt-info.u-strasbg.fr>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-78-147-23-67.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.0; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
In-Reply-To <87wqyga0cr.fsf@dpt-info.u-strasbg.fr>
X-Antivirus avast! (VPS 121023-2, 23/10/2012), Outbound message
X-Antivirus-Status Clean
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2728.1351059042.27098.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351059042 news.xs4all.nl 6964 [2001:888:2000:d::a6]:34249
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32005

Show key headers only | View raw


On 24/10/2012 06:46, Alain Ketterlin wrote:
> satyam <dirac.sat@gmail.com> writes:
>
>> I have a text file like this
>>
>> A1980JE39300007 2732 4195 12.527000
>> A1980JE39300007 3465 9720 22.000000
>> A1980JE39300007 2732 9720 18.000000
>> A1980KK18700010 130 303 4.985000
>> A1980KK18700010 7 4915 0.435000
> [...]
>> I want to split the file and get multiple files like
>> A1980JE39300007.txt and A1980KK18700010.txt, where each file will
>> contain column2, 3 and 4.
>
> Sorry for being completely off-topic here, but awk has a very convenient
> feature to deal with this. Simply use:
>
>      awk '{ print $2,$3,$4 > $1".txt"; }' /path/to/your/file
>
> -- Alain.
>

Although practicality beats purity :)

-- 
Cheers.

Mark Lawrence.

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


Thread

Split single file into multiple files based on patterns satyam <dirac.sat@gmail.com> - 2012-10-23 20:01 -0700
  Re: Split single file into multiple files based on patterns Jason Friedman <jason@powerpull.net> - 2012-10-23 21:36 -0600
  Re: Split single file into multiple files based on patterns Jason Friedman <jason@powerpull.net> - 2012-10-23 21:43 -0600
  Re: Split single file into multiple files based on patterns David Hutto <dwightdhutto@gmail.com> - 2012-10-24 01:24 -0400
  Re: Split single file into multiple files based on patterns Demian Brecht <demianbrecht@gmail.com> - 2012-10-23 22:36 -0700
  Re: Split single file into multiple files based on patterns Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-24 01:38 -0400
  Re: Split single file into multiple files based on patterns Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-10-24 07:46 +0200
    Re: Split single file into multiple files based on patterns Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-24 07:13 +0100
  Re: Split single file into multiple files based on patterns Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-24 07:52 +0000
    Re: Split single file into multiple files based on patterns David Hutto <dwightdhutto@gmail.com> - 2012-10-24 04:02 -0400
  Re: Split single file into multiple files based on patterns Peter Otten <__peter__@web.de> - 2012-10-24 10:17 +0200

csiph-web