Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32005
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: Split single file into multiple files based on patterns |
| Date | 2012-10-24 07:13 +0100 |
| References | <9ae3b43a-5c69-4232-a1cf-e2dd0c4ee2ca@googlegroups.com> <87wqyga0cr.fsf@dpt-info.u-strasbg.fr> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2728.1351059042.27098.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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