Re: String to numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg55361] Re: String to numbers
- From: bghiggins at ucdavis.edu
- Date: Sun, 20 Mar 2005 04:11:53 -0500 (EST)
- References: <d1gu3b$p0$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
John, Here is one way. let us suppose the data is in a file that we
import into Mathematica
data = Import["/Users/brian/Desktop/data.text", "CSV"]
Here is what the data looks like
data//FullForm
FullForm=List[List["<2.54 3.11 2.89> "],List["<3.58 5.24 5.66> "]]
Now we make use of StringToStream to create an input stream for each
String, and then use ReadList to read in each data point which is then
transformed into an expression
Map[ToExpression[ReadList[StringToStream[First[#]],
Word,WordSeparators->{"<"," ",">"}]]&,data]//FullForm
List[List[2.54`,3.11`,2.89`],List[3.58`,5.24`,5.66`]]
Cheers,
Brian