yamid

yamid

  • NA
  • 98
  • 0

read a text file and put it in an array

May 17 2011 5:17 PM
Hi ,
I have a text file saved in  C:\PROG\t.txt . Apart of the text file which is interested is in below.
I want the program to read the text file and find the the values right after "BIC" that terminate with the slash and put them in a 8*8 array
BIC[,]=new double [8,8];
in which each line is i and each column is j. if there is not enough values it should be considered as "zero".
I mean:
BIC[0,0]=.09938 , BIC[0,1]=0,..., BIC[0,7]=0
BIC[1,0]=.13000, BIC[1,1]=.00081, BIC[1,2]=0,..., BIC[1,7]=0
...

Thanks







A part of my TEXT FILe :

-- Shift coefficients for EoS
SSHIFT
  -0.08652 -0.05010 -0.00502  0.00035  0.00580
  0.04460  0.04532  0.04978  0.07032  0.08532 /


-- Binary interaction coefficients for EoS
BIC
.09938
.13000 .00081
.13090 .00262 .00103
.12076 .00583 .00397 .00000
.11887 .07122 .01438 .00504 .00080
.11859 .07232 .02062 .00905 .00216 .00036
.11859 .07993 .03723 .01827 .00625 .00267 .00003
.11847 .09926 .05789 .02799 .01083 .00607 .00011 .00000
.11849 .10308 .06488 .03601 .01343 .00809 .00020 .00001 .00000
/


-- Component parachors
PARACHOR
  76.7 66.454 100.839 154.612 223.309 314.477 579.64 695.812 995.076 1590.748 /

Answers (3)