Joining data from three different files to be written into three Columns
I have three files of binary data. I want to write the three binary data files to one file. I want the old files to each have their own column in the new file. This is what I have, f=open('relative_x.INT32','rb') a=array('l') a.fromfile(f,10) g=open('relative_y.INT32','rb') b=array('l') b.fromfile(g,10) data=zip(a,b) for datum in data: ...print ' '.join(datum) ... the error I get is expected string, found int I figure that the joint is for strings only does anyone know of a way were I could join the data that would be for ints. Thanks Dawn -- http://mail.python.org/mailman/listinfo/python-list
Re: Joining data from three different files to be written into three Columns
No, two of the binary data files are integers and the third file is a float. The data is large and the binary saves time and space. On 11/29/06, Gabriel Genellina <[EMAIL PROTECTED]> wrote: At Wednesday 29/11/2006 23:07, Dawn Abbott wrote: >I have three files of binary data. I want to write the three binary >data files to one file. I want the old files to each have their own >column in the new file. This is what I have, > >f=open('relative_x.INT32','rb') >a=array('l') >a.fromfile(f,10) >g=open('relative_y.INT32','rb') >b=array('l') >b.fromfile(g,10) >data=zip(a,b) >for datum in data: >...print ' '.join(datum) >... > > >the error I get is expected string, found int >I figure that the joint is for strings only does anyone know of a >way were I could join the data that would be for ints. Do you want to write a TEXT representing the binary values? for datum in data: print ' '.join(map(str,datum)) -- Gabriel Genellina Softlab SRL __ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar -- http://mail.python.org/mailman/listinfo/python-list
Re: Joining data from three different files to be written into three Columns
On 11/29/06, Dawn Abbott <[EMAIL PROTECTED]> wrote: I have three files of binary data. I want to write the three binary data files to one file. I want the old files to each have their own column in the new file. This is what I have, f=open('relative_x.INT32','rb') a=array('l') a.fromfile(f,10) g=open('relative_y.INT32','rb') b=array('l') b.fromfile(g,10) data=zip(a,b) for datum in data: ...print ' '.join(datum) ... the error I get is expected string, found int I figure that the joint is for strings only does anyone know of a way were I could join the data that would be for ints. Thanks Dawn -- http://mail.python.org/mailman/listinfo/python-list
Re: Joining data from three different files to be written into three Columns
Everything works in my program except for when it prints out the number is surrounded by brackets but I need to print the number without the brackets. Does anyone know an easy way to do this? #!/usr/bin/env python import array fin = open('relative_x.INT32','rb') fin1=open('relative_y.INT32','rb') fin2=open('income.INT32','rb') outfile=open('test.txt','w') data=[] data1=[] data2=[] while True: try: myInts=array.array('l') myInts.fromfile(fin,1) data.append(myInts.tolist()) myInts1=array.array('l') myInts1.fromfile(fin1,1) data1.append(myInts1.tolist()) myInts2=array.array('l') myInts2.fromfile(fin2,1) data2.append(myInts2.tolist()) data3=zip(data,data1,data2) except EOFError: break for record in data: print record[0],record[1],record[2] thanks Dawn -- http://mail.python.org/mailman/listinfo/python-list