MathGroup Archive 2005

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

Search the Archive

Re: Reading from a file.

  • To: mathgroup at
  • Subject: [mg56688] Re: [mg56678] Reading from a file.
  • From: "David Annetts" <davidannetts at>
  • Date: Wed, 4 May 2005 00:32:53 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

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"}];
data = Flatten[data]
proc = ReadList[StringToStream[#], Table[Number, {6}]]& /@ data
proc = Partition[Flatten[proc], 6]

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.



  • Prev by Date: Re: Creating forms for user input in Mathematica
  • Next by Date: Re: GUIkit problem
  • Previous by thread: Re: Reading from a file.
  • Next by thread: Re: Reading from a file.