Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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

Re: ReadList with mixed strings and numbers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34859] Re: [mg34813] ReadList with mixed strings and numbers
  • From: Rolf Mertig <rolf at mertig.com>
  • Date: Tue, 11 Jun 2002 05:00:22 -0400 (EDT)
  • Organization: Mertig Consulting
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
one possibility is:

MixedRead[str_String, numformat_:{Number, Number}] := Block[{f, numcheckQ},
        f = ReadList[str, String];
        numcheckQ = (Complement[Characters[#],
         {"0","1","2","3","4","5","6","7","8","9","E","e","-",
          "+","^"," ",".", "\n","\r","\t"}     ] === {} )&;
        Table[If[numcheckQ[f[[i]]], 
        Read[StringToStream[f[[i]]], numformat], f[[i]]], {i, Length[f]} ] ]

--
Dr. Rolf Mertig
Mertig Consulting, Berlin, Germany
(web)Mathematica Programming and Training
http://www.mertig.com



  • Prev by Date: inverse square law attraction
  • Next by Date: Re: Does Mathematica runs in Windows XP?
  • Previous by thread: ReadList with mixed strings and numbers
  • Next by thread: Sorting with absolute precision