Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: format for reading 'yyyymmddTHHMMSS'
Replies: 3   Last Post: Nov 18, 2012 10:24 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Arun Upadhayaya

Posts: 2
Registered: 11/17/12
Re: format for reading 'yyyymmddTHHMMSS'
Posted: Nov 18, 2012 2:35 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Thx. Dnb,
The file i have is a csv file which has 25 description in it and reads like
1998-12-24T03:47:00.000,1998-12-24T04:08:00.000,1998-12-24T03:48:05.698, 917,54, 23.3........folowed by data.

i am reading the file by putting:
header = textscan(fid, '%[^,],%[^,],%4d-%2.2d-%2.2dT%2.2d:%2.2d:%06.3f,%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%f,%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,\r\n]', 1);

and than writing only the 3rd decription to output.

by:
for i=3;
occtime=header{i};
end;
formatSpec = '%d-%2.2d-%2.2dT%2.2d:%2.2d:%06.3f';
fprintf(formatSpec,occtime);
but t is just printing 1998 in place of 1998-12-24T03:48:05.698

pl. comment
regards



dpb <none@non.net> wrote in message <k88i1f$4gu$1@speranza.aioe.org>...
> 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 .
> >
> > datestr converts the format but i need to just display and existing date
> > time from file 1998-12-24T03:48:05.698.

>
> I can't parse from the post precisely which form it is you have--text or
> datenum but since if it were already text it would seem your problem
> would be solved 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 =
> 1998-12-24T03:48:05.698

> >>
>
> doc sprintf % and friends for formatting
>
> --




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.