Re: Split single file into multiple files based on patterns

2012-10-24 Thread Peter Otten
satyam wrote: > I have a text file like this > > A1980JE3937 2732 4195 12.527000 > A1980JE3937 3465 9720 22.00 > A1980JE3937 1853 3278 12.50 > A1980JE3937 2732 2732 187.50 > A1980JE3937 19 4688 3.619000 > A1980JE3937 2995 9720 6.667000 > A1980JE3937 1603 97

Re: Split single file into multiple files based on patterns

2012-10-24 Thread David Hutto
On Wed, Oct 24, 2012 at 3:52 AM, Steven D'Aprano wrote: > On Tue, 23 Oct 2012 20:01:03 -0700, satyam wrote: > >> I have a text file like this >> >> A1980JE3937 2732 4195 12.527000 > [...] > >> I want to split the file and get multiple files like A1980JE3937.txt >> and A1980KK18700010.txt,

Re: Split single file into multiple files based on patterns

2012-10-24 Thread Steven D'Aprano
On Tue, 23 Oct 2012 20:01:03 -0700, satyam wrote: > I have a text file like this > > A1980JE3937 2732 4195 12.527000 [...] > I want to split the file and get multiple files like A1980JE3937.txt > and A1980KK18700010.txt, where each file will contain column2, 3 and 4. Are you just excite

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Mark Lawrence
On 24/10/2012 06:46, Alain Ketterlin wrote: satyam writes: I have a text file like this A1980JE3937 2732 4195 12.527000 A1980JE3937 3465 9720 22.00 A1980JE3937 2732 9720 18.00 A1980KK18700010 130 303 4.985000 A1980KK18700010 7 4915 0.435000 [...] I want to split the file

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Alain Ketterlin
satyam writes: > I have a text file like this > > A1980JE3937 2732 4195 12.527000 > A1980JE3937 3465 9720 22.00 > A1980JE3937 2732 9720 18.00 > A1980KK18700010 130 303 4.985000 > A1980KK18700010 7 4915 0.435000 [...] > I want to split the file and get multiple files like > A19

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Demian Brecht
On 2012-10-23, at 10:24 PM, David Hutto wrote: > count = 0 Don't use count. > for file_data in turn_text_to_txt: Use enumerate: for count, file_data in enumerate(turn_text_to_txt): > f = open('/home/david/files/%s_%s.txt' % (file_data.split(' ')[0], count), > 'w') Use with: with open('file

Re: Split single file into multiple files based on patterns

2012-10-23 Thread David Hutto
On Tue, Oct 23, 2012 at 11:01 PM, satyam wrote: > I have a text file like this > > A1980JE3937 2732 4195 12.527000 > A1980JE3937 3465 9720 22.00 > A1980JE3937 1853 3278 12.50 > A1980JE3937 2732 2732 187.50 > A1980JE3937 19 4688 3.619000 > A1980JE3937 2995 9720 6

Re: Split single file into multiple files based on patterns

2012-10-23 Thread satyam mukherjee
Thanks I will take a look...My actual data is 2.5Gb in size. Satyam On Tue, Oct 23, 2012 at 10:43 PM, Jason Friedman wrote: > On Tue, Oct 23, 2012 at 9:01 PM, satyam wrote: > > I have a text file like this > > > > A1980JE3937 2732 4195 12.527000 > > A1980JE3937 3465 9720 22.00 > > A1

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Jason Friedman
On Tue, Oct 23, 2012 at 9:01 PM, satyam wrote: > I have a text file like this > > A1980JE3937 2732 4195 12.527000 > A1980JE3937 3465 9720 22.00 > A1980JE3937 1853 3278 12.50 > A1980JE3937 2732 2732 187.50 > A1980JE3937 19 4688 3.619000 > A1980KK18700010 30 186 1.285

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Jason Friedman
> I have a text file like this > > A1980JE3937 2732 4195 12.527000 > A1980JE3937 3465 9720 22.00 > A1980KK18700010 186 3366 4.78 > A1980KK18700010 30 186 1.285000 > A1980KK18700010 30 185 4.395000 > A1980KK18700010 185 186 9.00 > A1980KK18700010 25 30 3.493000 > > I want to spli

Split single file into multiple files based on patterns

2012-10-23 Thread satyam
I have a text file like this A1980JE3937 2732 4195 12.527000 A1980JE3937 3465 9720 22.00 A1980JE3937 1853 3278 12.50 A1980JE3937 2732 2732 187.50 A1980JE3937 19 4688 3.619000 A1980JE3937 2995 9720 6.667000 A1980JE3937 1603 9720 30.00 A1980JE3937 234