Re: Difficulty in importing dates and times with functions like
- To: mathgroup at smc.vnet.net
- Subject: [mg94427] Re: Difficulty in importing dates and times with functions like
- From: ADL <alberto.dilullo at tiscali.it>
- Date: Fri, 12 Dec 2008 06:58:02 -0500 (EST)
- References: <ghqk47$18l$1@smc.vnet.net> <ghr11c$8rk$1@smc.vnet.net>
Thank you for the good suggestion. I also noticed that regular
expressions are quite faster than string patterns.
On my pc (notice ten times more evaluations than in your example):
In[]:= abstime[t_String] := AbsoluteTime[ToExpression[StringSplit[t,
"-" | " " | ".", 6]]];
In[]:= Do[r1 = abstime["2008-12-01 12.34.56.454"], {100000}] // Timing
Out[]= {3.869,Null}
while
In[]:= abstime[t_String] := ToExpression[StringSplit[t,
RegularExpression["[- .]"], 6]];
In[]:= Do[ r1 = abstime["2008-12-01 12.34.56.454"], {100000}] //
Timing
Out[]= {2.823,Null}
Thanks
Al
On 11 Dic, 13:28, Raffy <ra... at mac.com> wrote:
> abstime[t_String] := AbsoluteTime[ToExpression[StringSplit[t, "-" | "
> " | ".", 6]]];
>
> Do[r1 = abstime["2008-12-01 12.34.56.454"], {10000}] // Timing
> ==> 0.2 sec
>
> Do[r2 = AbsoluteTime[{"2008-12-01 12.34.56.454", {"Year", "Month",
> "Day", "Hour", "Minute", "Second"}}], {10000}] // Timing ==> 27 sec
>
> Floor[r1] == r2 ==> True