Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

ReadList with mixed strings and numbers

  • To: mathgroup at
  • Subject: [mg34813] ReadList with mixed strings and numbers
  • From: Goyder Dr HGD <H.Goyder at>
  • Date: Sat, 8 Jun 2002 05:21:23 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

A data capture system gives me an ASCII file which I wish to read into
Mathematica for analysis.
The file contains strings of useful information, such as date and time of
capture and sample rate, followed by data pairs, as approximate numbers in
"E" format. The numbers are followed by more strings and then more
What I would like to do is to use a sequence of ReadLists as follows


however I do not know the size of n1, n2, n3, n4... so I can't do the above.

I can do 

and read everything as a String. I then have to sort out the strings into
strings and numbers which I attempt to do using 

h = {}; d = {};
Do[If[t = Read[StringToStream[a[[i]]], {Number, Number}];
NumberQ[t[[1]]] == True, AppendTo[d, t], AppendTo[h, a[[i]]]], 

which works but gives me warning messages and may not be foolproof.

Is there a recommended method for reading data which consists of mixed
strings and numbers so that the numbers get recognised as numbers and the
strings as strings?

Hugh Goyder

  • Prev by Date: RE: Graphics
  • Next by Date: Re: Graphics
  • Previous by thread: How can I turn a display into an output ?
  • Next by thread: Re: ReadList with mixed strings and numbers