Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3124

Re: Is there ToNumber?

From "Hans Michel" <hmichel@cox.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Is there ToNumber?
Date 2011-06-16 08:02 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <itcd9t$d0b$1@smc.vnet.net> (permalink)
References <isnllk$n7b$1@smc.vnet.net> <201106090945.FAA06238@smc.vnet.net> <isv78n$80$1@smc.vnet.net> <201106141151.HAA07409@smc.vnet.net> <201106151119.HAA22765@smc.vnet.net>

Show all headers | View raw


Is it possible that you can post a few representative file names with the
time stamps.  

Assuming that the "file name+time stamp + . + extension" is the file name.
Otherwise you may be speaking of file attributes. If you clarify your
problem to the group, you will probably have more answers to choose from.
But you seem to be hitting a road block and finding a solution and feel that
it maybe awkward. 

Please post a representation of the problem and then your desired end point.
The raw data not the step you feel may have a better solution.

Mathematica has numerous DateTime functions and numerous functions for
directory information.

I feel that you may be asking a question such as:
  What is an efficient way to grab a time stamp from a file name or file
attribute and serialize that time stamp to a number so I can sort it or do
something else with that number?.

Hans

-----Original Message-----
From: Ted Sariyski [mailto:tsariysk@craft-tech.com] 
Sent: Wednesday, June 15, 2011 6:19 AM
Subject: Re: Is there ToNumber?

Hi,
>  would be necessary to specify where these strings come from...

I had to extract the time stamp from the file names.

>Is there a reason why you
>think that is not good enough?

That is exactly what I am doing and it works fine. The only reason I 
posted the question was because I felt that I am missing  something.

Thanks,
--Ted

  On 6/14/2011 7:51 AM, Albert Retey wrote:
> Hi,
>
> the short answer is: no.
>
>> Is there a built-in function which returns the numeric value of a string
>> (like ToString but inverse).  Currently I use mine function toNumber:
>>
>>     ch = StringToStream[timeStr];
>>     timeNum = Read[ch, Number];
>>     Close[ch];
>>
>> but I suspect there is easier way.
> The question is what kind of input you expect "ToNumber" to handle. As
> others have pointed out ToExpression is the most simple and also
> relatively fast but only works for numbers given in Mathematica syntax.
> If you need to handle other formats, then there are alternatives to what
> you do, but they seem to be slower if used in a naive way, e.g.:
>
> ImportString["1e3", "Table"][[1, 1]]
>
> whether you consider that to be "easier" is another question. What about
> defining:
>
> toNumber[s_String] := Module[{ch, res},
>     ch = StringToStream[s];
>     res = Read[ch, Number];
>     Close[ch];
>     res
>     ];
>
> This is easy to use and also relatively fast. Is there a reason why you
> think that is not good enough? If you need further advice, I think it
> would be necessary to specify where these strings come from...
>
> hth,
>
> albert
>


Back to comp.soft-sys.math.mathematica | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: How show axes labels with AxesOrigin->{0,0,0} in 3D? Murray Eisenberg <murray@math.umass.edu> - 2011-06-08 11:16 +0000
  Re: How show axes labels with AxesOrigin->{0,0,0} in 3D? Peter Breitfeld <phbrf@t-online.de> - 2011-06-09 09:45 +0000
  Is there ToNumber? Ted Sariyski <tsariysk@craft-tech.com> - 2011-06-11 07:59 +0000
    Re: Is there ToNumber? Albert Retey <awnl@gmx-topmail.de> - 2011-06-14 11:52 +0000
    How to extract a pattern Ted Sariyski <tsariysk@craft-tech.com> - 2011-06-15 11:20 +0000
    Re: Is there ToNumber? "Hans Michel" <hmichel@cox.net> - 2011-06-16 08:02 +0000
  Re: Is there ToNumber? "Dr. Peter Klamser" <klamser@googlemail.com> - 2011-06-11 10:52 +0000
  Re: Is there ToNumber? "Harvey P. Dale" <hpd1@nyu.edu> - 2011-06-12 09:07 +0000
  Re: Is there ToNumber? ADL <alberto.dilullo@tiscali.it> - 2011-06-12 09:07 +0000
  Re: Is there ToNumber? "Hans Michel" <hmichel@cox.net> - 2011-06-12 23:00 +0000
  Re: Is there ToNumber? "Dr. Peter Klamser" <klamser@googlemail.com> - 2011-06-12 23:01 +0000
  Re: Is there ToNumber? DrMajorBob <btreat1@austin.rr.com> - 2011-06-15 11:19 +0000
  Re: Is there ToNumber? Daniel Lichtblau <danl@wolfram.com> - 2011-06-15 11:19 +0000

csiph-web