Reading data from file: x(i),y(i) form

S

Satish Chimakurthi

Hi all,

I have data of the following form in a file called "fluid_grid.dat"

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

The first column gives values of x and the second, the values of y

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.

ifile4=open('fluid_grid.dat','r')
lines=ifile4.readlines( )
x=[ ]
y=[ ]
i=1
for line in lines:
x,y=map(float,line.replace('D','E').split( ))
i=i+1
if i==7:
break

I get the following error:

x,y=map(float,line.replace('D','E').split( ))
Index Error: list index out of range


Can someone help me ? Please let me know if there is a better way to serve my purpose.


Thanks

Regards,
Satish Kumar Chimakurthi



SATISH KUMAR CHIMAKURTHI
Graduate Research Assistant
CFD GROUP
Mechanical Engineering
UNIVERSITY OF KENTUCKY
Lexington
KENTUCKY - 40508
U.S.A

Email: (e-mail address removed)
Mobile:859-420-9890
Office: 859-257-6336 X 80691
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top