MathGroup Archive 2001

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

Search the Archive

Re: String to Number

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27168] Re: [mg27156] String to Number
  • From: Ken Levasseur-UML <Kenneth_Levasseur at uml.edu>
  • Date: Fri, 9 Feb 2001 03:10:17 -0500 (EST)
  • References: <200102080940.EAA22639@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Steffen:

Here is one way to do it.  It assumes the presence of a semicolon to
identify the two parts.

tstrings = {"06:42", "12:30", "1:22", "13:45"};
In[57]:=
convert[t_String] := (t //
        Characters) /. {{a__, ":",
          b__} :> (ToExpression[StringJoin[#]] & /@ {{a}, {b}})}
In[58]:=
convert /@ tstrings
Out[58]=
{{6, 42}, {12, 30}, {1, 22}, {13, 45}}


Ken Levasseur
Math Sciences
UMass Lowell

steffenz at server2.fo.FH-Koeln.DE wrote:

> Hi
>
> I read a time from a file (this format  06:42) as a string.
>
> I would like to convert this string into to numbers (6 and 42).
>
> any suggestions?
>
> Thanks
>
> Steffen
>
>
> Dipl.-Ing. Steffen Zozgornik
>
> Institut fur Licht- und Bautechnik
> an der Fachhochschule Koeln
> Gremberger Strasse 151 a
> D - 51105 Koeln
>
> Tel.: +49 - 221 - 83 10 95
> Fax.: +49 - 221 - 83 55 13



  • Prev by Date: Re: String to Number
  • Next by Date: Re: Genetic Algorithms?
  • Previous by thread: String to Number
  • Next by thread: Re: String to Number