Reading data from file: x(i),y(i) form
Robert Brewer
fumanchu at amor.org
Fri Feb 27 16:58:36 EST 2004
Satish Chimakurthi wrote:
> I have data of the following form
>
> 1.00000000000000 0.00000000000000D+000
> 0.959753969508636 0.280842158538236
> 0.842255363975169 0.539078752924891
> 0.656961888321583 0.753923787456623
> 0.418788196289889 0.908083942512068
> 0.146905379223583 0.989150549489397
>
> My aim is to read the data into x(i), y(i) where
> i=1,6, and I wrote the following code for the purpose.
Try this:
ifile4=open('fluid.dat','r')
points = []
for i, line in enumerate(ifile4.readlines()):
points.append(map(float,line.replace('D','E').split()))
if i==7:
break
print points
Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org
More information about the Python-list
mailing list