I am looking for some pointers on how to format float numbers in a numpy array. This code selects lines from an array, and I want the output to look better so I can import into excel.
infile looks like this:
1074 CL 006 2004 A8LGPUYE 10 TY 2 S0111P 2
from numpy import * infile = open("C:\Python25\Drew\idage.txt", 'r') outfile= open("CLrcwarray.txt",'w') rcw = infile.readlines() bird_a =  known =  ct=0 CLrcw=zeros((4813,5),float) for record in rcw: bird = record.strip().split() nID=int(bird) ter=int(bird) year=int(bird) ## status=int(bird) fled=int(bird) age=float(bird) CLrcw[ct,0]=nID CLrcw[ct,1]=ter CLrcw[ct,2]=year CLrcw[ct,3]=fled CLrcw[ct,4]=age ct+=1 for each in CLrcw: age2 = each if age2 > 0: outfile.writelines("%s \n" %(each))
So the output puts the last item of the array on the next line and I need it all on the same line.
[ 1.07400000e+03 6.00000000e+00 2.00400000e+03 2.00000000e+00
I also would like to the numbers with less zeros where it would be easier to read.