Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Convert string list to number list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106625] Re: Convert string list to number list
  • From: Canopus56 <canopus56 at yahoo.com>
  • Date: Tue, 19 Jan 2010 05:13:00 -0500 (EST)
  • References: <hj12ud$b9u$1@smc.vnet.net> <4B5440B9.8010208@metrohm.com>

Thanks to all who replied.  Even with ToExpression, I was trouble getting the string to numeric conversion to persistently take when replacing to a list. There was some weird runtime error where you could run and get: 

lstTriple =lstTriple/.{x_,y_,z_}->{x,ToExpression[y],z}

lstTriple;

NumericQ[listTriple[[3,2]]]
True

lstTriple; 


NumericQ[listTriple[[3,2]]]
False

After splitting out the column containing numeric string data explicitly to a new single variable list, then running the Map function using ToExpression, and then reassembling the list triple, would Mathematica recognize the numeric and not string format persistently. 

Thanks again for the help. - Kurt 


----- Original Message ----
From: dh <dh at metrohm.com>
To: Canopus56 <canopus56 at yahoo.com>
Sent: Mon, January 18, 2010 4:06:33 AM
Subject: [mg106625] Re: Convert string list to number list

Hi,
if you do not want it to convert on input, you may still use e.g. ToExpression:
ToExpression@{"00", "01", "02", "03", "04", "05", "06", "07"}
Daniel


Canopus56 wrote:
> On importing a space delimited text file,  I have an extracted list of zero-padded two-digit integers in the form: Amylist{"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"}  How do I convert these to real numbers or integers? Thanks - Kurt  I have reviewed the Mathematica documentation and a few books looking for the equivalent of a simple string-to-number function like vba's "Value".  Could not find an answer. Thanks.      


      


  • Prev by Date: Re: More /.{I->-1} craziness, con brio
  • Next by Date: Re: First function debug help
  • Previous by thread: Re: Convert string list to number list
  • Next by thread: Re: Convert string list to number list