cotj73
asked on
Reading text from a file
I need to be able to read text from a file, and save it somehow to a grid like excell, the format inside the file is as follows
"ZERNIKE"
"SCALE: 2.56245844477293E-03"
28
0
7.26319504749052E-04
-1.28435703005351E-04
-4.70736639230834E-04
-2.11696194741656E-04
-6.94188170158255E-06
1.21760327335195E-05
-1.16471189175351E-04
1.892881053328E-04
2.43394089421797E-05
-4.27588262279435E-06
3.96428568852939E-05
1.21416458423661E-05
-5.07598197431613E-06
2.42835581669891E-05
1.84678127720032E-05
-1.6793619674676E-05
-5.20898049006682E-06
-1.76892518358479E-05
-7.00485451263667E-06
1.38926890110059E-05
-1.61087650649244E-05
1.32222083318142E-05
2.28048832601142E-05
4.92909574194228E-05
-3.9719165605381E-05
-3.30874305806735E-05
4.36658825006991E-05
-1
0
-1
-5.05906053272166E-03
-3.51320393781458E-03
6.18699368903292E-04
4.7028011256734E-04
1003597
Each line is needed in a different cell. moving to the right, essentially in the same row of a multidemensional array.
Many of these files will be pulled in sequence.
If needed i can split this up into different questions, i just do not know how to do this.
If i am unclear, Please ask questions
"ZERNIKE"
"SCALE: 2.56245844477293E-03"
28
0
7.26319504749052E-04
-1.28435703005351E-04
-4.70736639230834E-04
-2.11696194741656E-04
-6.94188170158255E-06
1.21760327335195E-05
-1.16471189175351E-04
1.892881053328E-04
2.43394089421797E-05
-4.27588262279435E-06
3.96428568852939E-05
1.21416458423661E-05
-5.07598197431613E-06
2.42835581669891E-05
1.84678127720032E-05
-1.6793619674676E-05
-5.20898049006682E-06
-1.76892518358479E-05
-7.00485451263667E-06
1.38926890110059E-05
-1.61087650649244E-05
1.32222083318142E-05
2.28048832601142E-05
4.92909574194228E-05
-3.9719165605381E-05
-3.30874305806735E-05
4.36658825006991E-05
-1
0
-1
-5.05906053272166E-03
-3.51320393781458E-03
6.18699368903292E-04
4.7028011256734E-04
1003597
Each line is needed in a different cell. moving to the right, essentially in the same row of a multidemensional array.
Many of these files will be pulled in sequence.
If needed i can split this up into different questions, i just do not know how to do this.
If i am unclear, Please ask questions
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
After reading the file you can apply the regular expression to filter out the data!
and here you go!
and here you go!
System.IO.StreamReader rdr = new System.IO.StreamReader(filename);
string allText = rdr.ReadToEnd();
ASKER
Great Help Thank You
eg. if you wanted to put each line from the file into the next cell in excel
Open in new window