Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Fwd: How to extract numbers from list elements with text?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70428] Fwd: How to extract numbers from list elements with text?
  • From: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>
  • Date: Mon, 16 Oct 2006 02:34:32 -0400 (EDT)
  • References: <egn9a3$1em$1@smc.vnet.net> <452F511C.1060107@gmail.com>

[...second attempt...]

---------- Forwarded message ----------
From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
To: mathgroup at smc.vnet.net
Subject: [mg70428] Re: How to extract numbers from list elements with text?


Henning Heiberg-Andersen wrote:
> Hi,
>
> I have a list looking like this:
>
> { 1 Intensity 0.23523,  2 Intensity 0.00005,  3 Intensity 0.00004, ..}
>
> Is there a command which allows extraction of only the last number appearing
> in each element
> of the list?. If not, how can I modify the list elements?
>
> Best regards,
>
> Henning Heiberg-Andersen
>
>
As written, Mathematica is going to undergo some simplifications and
assume that a space is an implicit multiplication.

In[1]:=
{1 Intensity 0.23523,2 Intensity 0.00005,3 Intensity 0.00004}

Out[1]=
{0.23523 Intensity,0.0001 Intensity,0.00012 Intensity}

To avoid this, your data must be imported/transformed as a list of list.
Then, extracting the third column is straightforward.

In[1]:=
data=ReleaseHold[HoldForm[{1 Intensity 0.23523,2 Intensity 0.00005,3
Intensity 0.00004}] /. Times -> List]

Out[1]=
{{1,Intensity,0.23523},{2,Intensity,0.00005},{3,Intensity,0.00004}}

In[2]:=
data[[All,3]]

Out[2]=
{0.23523,0.00005,0.00004}

Regards,
Jean-Marc


  • Prev by Date: Re: FourierSinTransform
  • Next by Date: Re: General--Simple Permutations
  • Previous by thread: Re: How to extract numbers from list elements with text?
  • Next by thread: Re: How to extract numbers from list elements with text?