MathGroup Archive 2010

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

Search the Archive

Re: Re: Convert string list to number list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106694] Re: [mg106659] Re: Convert string list to number list
  • From: Canopus56 <canopus56 at yahoo.com>
  • Date: Thu, 21 Jan 2010 04:53:31 -0500 (EST)
  • References: <201001201149.GAA09247@smc.vnet.net>

> Since there is no object in Mathematica that can be used as an
> argument for NumbericQ that will return True and False, you must
> have done something you are not showing above that would explain
> the result.

Thanks, Bill.  No, I haven't done something else between the first and second NumericQs.  I was just illustrating anomalous behavior by the program.  The only way to kill the runtime error was to deconstruct the triple into three lists of singles,  run "ToExpression" on a one dimensional array {y}, and then reassemble a new triple.

No worries.  It is probably something in the source data.  It's fixed with a brute force, but inelegant solution.

Thanks again, Kurt 

----- Original Message ----
From: Bill Rowe <readnews at sbcglobal.net>
To: mathgroup at smc.vnet.net
Sent: Wed, January 20, 2010 4:49:38 AM
Subject: [mg106694] [mg106659] Re: Convert string list to number list

On 1/19/10 at 5:13 AM, canopus56 at yahoo.com (Canopus56) wrote:

>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

Since there is no object in Mathematica that can be used as an
argument for NumbericQ that will return True and False, you must
have done something you are not showing above that would explain
the result.

>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.

After reading this several times, I cannot determine whether you
still have a problem or exactly what you are saying Mathematica
is doing. I will note since

In[6]:= Attributes[ToExpression]

Out[6]= {Listable,Protected}

it is not necessary to use Map in order to covert each string in
a list of strings to a number using ToExpression.


      


  • Prev by Date: Re: Sorting paired columns of dates and values
  • Next by Date: Number output formatting was Re: First function debug help
  • Previous by thread: Re: Convert string list to number list
  • Next by thread: Calculating zeta(1+it) for t in range of 10^12 accurately