Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Converting date strings to DateList format - a need for speed

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106507] Converting date strings to DateList format - a need for speed
  • From: Garapata <warsaw95826 at mypacks.net>
  • Date: Fri, 15 Jan 2010 03:16:36 -0500 (EST)

I have dates in the first column of large flat files (6000+ rows).
The flat files have a header row and may have as many as 20 columns of
data besides the dates.  A sample of a flat file follows

dataFile = {{"DATES", "DATA1", "DATA2"}, {"12/31/84", 1, 1},
{"01/01/85", 1,
  1.00239}, {"01/02/85", 0.999206, 1.00238}, {"01/03/85", 0.997425,
  1.00238}, {"01/04/85", 0.997038, 1.00237}, {"01/07/85", 0.989256,
  1.0071}, {"01/08/85", 1.00867, 1.00235}, {"01/09/85", 0.994708,
  1.00235}, {"01/10/85", 1.00552, 1.00234}}

I want to make a list of just the dates from the first column and turn
them into an unambiguous DataList[] format for later processing.

This works:

dates = DateList[{#, {"Month", "Day","YearShort"}}] & /@ (DateString
[#] & /@Rest[dataFile][[All, 1]]);

but, with thousands of dates in a file to convert, it takes a long
time to run.  The Map within a Map seems to slow things down a lot.
Unless I've missed something, (quite possible) neither DateList[] nor
DateString seem to operate directly on lists, so I haven't figured out
a better way to do this.

Can I do anything to make this run faster?  Any solutions much
appreciated.


  • Prev by Date: Re: Simplify with NestedLessLess?
  • Next by Date: Re: Differential Eq.
  • Previous by thread: Re: sketch a phase portrait for the nonlinear system
  • Next by thread: Re: Converting date strings to DateList format - a need for speed