Re: Reading from a file.
- To: mathgroup at smc.vnet.net
- Subject: [mg56688] Re: [mg56678] Reading from a file.
- From: "David Annetts" <davidannetts at aapt.net.au>
- Date: Wed, 4 May 2005 00:32:53 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Namrata,
< snippage>
>
> So the real numbers matrix is of size [7][6]
In Mathematica, the notation is {7,6} ....
>
> I have tried quite a few things but nothing seems to be working.
Really? What did you try? You may have been close to a solution, but who
can tell since there is no code ....
Anyway, it's not particularly efficient but
inpu = OpenRead["test.txt"]
data = ReadList[inpu, Record, RecordSeparators->{"%Object Name : left asis",
"%Object Name : right asis"}];
Close[inpu];
data = Flatten[data]
proc = ReadList[StringToStream[#], Table[Number, {6}]]& /@ data
proc = Partition[Flatten[proc], 6]
MatrixForm[proc]
Works for me.
Another version might use Find to skip over the problematic records and yet
another might export the first data record to yet another file & Import it.
Regards,
Dave.