MathGroup Archive 2010

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

Search the Archive

Re: Convert string list to number list


Am 18.01.2010 08:34, schrieb Canopus56:
> 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.
> 

The function you are looking for is called ToExpression. You need to map
it to your list of strings:

amylist={"02", "03", "04", "05", "06", "07", "08", "09"}

Map[ToExpression,amylist]

or abbreviated:

ToExpression /@ amylist

hth,

albert


  • Prev by Date: Re: Convert string list to number list
  • Next by Date: Re: Testing Mathematica Expressions?
  • Previous by thread: Re: Convert string list to number list
  • Next by thread: Re: Convert string list to number list