Re: Problem parsing date formats using Import
- To: mathgroup at smc.vnet.net
- Subject: [mg90517] Re: Problem parsing date formats using Import
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Fri, 11 Jul 2008 02:05:44 -0400 (EDT)
On 7/10/08 at 6:33 AM, rowland.jon at gmail.com (Jon) wrote: >I'm trying to parse a file which has dates in the format YYYYMMDD, >e.g. 20080101. However I just can't seem to get the DateStringFormat >to work - it works fine for YYYY-MM-DD or YYYYMM-DD but not if I >remove the separators entirely. Is this because of the ambiguity >between numeric and this date format? Most likely the issue is the ambiguity you describe above. But given >In[138]:= ImportString["198204-22\n198204-23", "Table", >"DateStringFormat" -> {"Year", "Month", "-", "Day"}] Out[138]= >{{{1982, 4, 22}}, {{1982, 4, 23}}} Does what you want, it seems the simple thing to do would be: In[8]:= ImportString[StringInsert["19820422", "-", -3], "Table", "DateStringFormat" -> {"Year", "Month", "-", "Day"}] Out[8]= {{1982,4,22}}