MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Multiple Headers in Data File

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23536] Multiple Headers in Data File
  • From: "Krautschik, Chris G" <krautschikc at intel.co.jp>
  • Date: Sat, 20 May 2000 03:10:16 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

All,

I would like to read in data from a data file that contains multiple
headers. Each header line begins with  the pound character. I would like to
read the data into a 2-D matrix. Note that I would like to test for the
pound character since I don't know the exact number of header lines in each
case.

Here is an example of the input data file:
-----------------------------------------
# beginning of file

# coherence data
# nx=4 ny=5
# x y y2
0.2 	1.23 	1.34E-9
NaN	-2.454	0.23E12
2.3	-9	1.23E-4

# coherence data 2
# nx=4 ny=5
# x y y3
-0.0	NaN	1.34E-9
NaN	-2.454	-0.23E12
122.3	2.34	3.43E-4
3.12	NaN	4.5

#end of file
---------------------------

Then the 4x6 Matrix should look like this:

0.2 	1.23 	1.34E-9 		-0.0	NaN	1.34E-9
NaN	-2.454	0.23E12		NaN	-2.454	-0.23E12
2.3	-9	1.23E-4		122.3	2.34	3.43E-4
				3.12	NaN	4.5
Note that the first three entries in the 4th row are absent. It would be
okay to fill the empty slots with either NaN or leave them blank all
together. Whichever is easier to program.

Any ideas on how to read in such a matrix would be greatly appreciated.

thanks,
Chris










  • Prev by Date: checking for a dead MathLink connection
  • Next by Date: ContourPlots,DensityPlots
  • Previous by thread: Re: checking for a dead MathLink connection
  • Next by thread: Re: Multiple Headers in Data File