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