MathGroup Archive 2001

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

Search the Archive

ReadList, mix Words & Numbers?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30880] ReadList, mix Words & Numbers?
  • From: Robert Love <rlove at neosoft.com>
  • Date: Fri, 21 Sep 2001 04:04:19 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I'm trying to read a text file, the so called Yuma format of the GPS
Almanac.  Each  entry is 15 lines line, the last being a blank and the
first being a string I don't care about.  I want to build lists of
numbers from the file.  I see how to read whole records but can't find
how to extract just the numbers I want.

A short version of the file looks like (best in monospaced font):

******** Week   99 almanac for PRN-01 ********
ID:                         01
Health:                     000
Eccentricity:               0.5095005035E-002
Time of Applicability(s):  319488.0000
Orbital Inclination(rad):   0.9654515552
Rate of Right Ascen(r/s):  -0.7623174679E-008
SQRT(A)  (m 1/2):           5153.727051
Right Ascen at Week(rad):   0.2834075570E+001
Argument of Perigee(rad):  -1.702684969
Mean Anom(rad):            -0.1280187112E+001
Af0(s):                     0.1859664917E-003
Af1(s/s):                   0.0000000000E+000
week:                         99

******** Week   99 almanac for PRN-02 ********
ID:                         02
Health:                     000
Eccentricity:               0.2133750916E-001
Time of Applicability(s):  319488.0000
Orbital Inclination(rad):   0.9324469998
Rate of Right Ascen(r/s):  -0.8183198006E-008
SQRT(A)  (m 1/2):           5153.597656
Right Ascen at Week(rad):  -0.1453525443E+001
Argument of Perigee(rad):  -2.027413647
Mean Anom(rad):             0.1975929042E+001
Af0(s):                    -0.4577636719E-004
Af1(s/s):                  -0.7275957614E-011
week:                         99
Each  non blank line that is not the header string consists of a label, a colon,
 and a number.    Reading like this:

rawdata = ReadList["almanac.txt",
    Table[{Record}, {14}], RecordSeparators -> {"\n"}]

gives me uniform records but my other attempts fail.  

rawdata = ReadList["Macintosh HD:Users:rlove:almanac.txt",
    {Record, Table[{Word, Word}, {13}]}, RecordSeparators -> {"\n"}, 
    WordSeparators -> {":"}, NullRecords -> False]

gives me good results but when I change to Number, like this:

rawdata = ReadList["Macintosh HD:Users:rlove:almanac.txt",
    {Record, Table[{Word, Number}, {13}]}, RecordSeparators -> {"\n"}, 
    WordSeparators -> {":"}, NullRecords -> False]

I get an error about reading a number.

My general question is:  How do I read a line of mixed text and numbers and 
extract just the numbers?  All advice appreciated.



  • Prev by Date: Re: export graphics on a Suse Linux 7.0 PC
  • Next by Date: Re: NIntegrate Precision
  • Previous by thread: Re: New user of Mathematica (FORTRAN related question)
  • Next by thread: Re: ReadList, mix Words & Numbers?