Date: Nov 18, 2012 10:24 AM
Subject: Re: format for reading 'yyyymmddTHHMMSS'
On 11/18/2012 1:35 AM, Arun Upadhayaya wrote:
...[top posting repaired--please don't do that; hard follow conversation
> dpb <firstname.lastname@example.org> wrote in message <email@example.com>...
>> On 11/17/2012 10:41 AM, Arun Upadhayaya wrote:
>> > I have to read and print as output datetime format 'yyyymmddTHHMMSS' to
>> > a file. Suggest me what format i can use for the same .
>> ... I'll presume you have a datenum something like
>> >> dn=datenum(1998,12,24,3,48,5.698);
>> >> sprintf('%4d-%2.2d-%2.2dT%2.2d:%2.2d:%06.3f',datevec(dn))
>> ans =
> Thx. Dnb,
> The file i have is a csv file which has 25 description in it and reads
> 917,54, 23.3........folowed by data.
> i am reading the file by putting:
> header = textscan(fid,
>> and than writing only the 3rd de[s]cription to output.
>> for i=3;
>> formatSpec = '%d-%2.2d-%2.2dT%2.2d:%2.2d:%06.3f';
>> but t is just printing 1998 in place of 1998-12-24T03:48:05.698
Well, first off what does header contain? Does the input work as
expected? It looks strange to me but I don't really know what you're
trying to do specifically, but...
If it is a csv file, why aren't you using 'delimiter',',' and then
skipping the fields you don't want instead of trying to parse (I guess
that's the intent of the %[^,]?).
fmt='%*s %*s %4d-%2d-%2dT%2d:%2d:%6f repmat('%*s,6,1) %*[^\n]';