comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Read ASCII time format question!!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Read ASCII time format question!! [message #89442 is a reply to message #89439] Thu, 16 October 2014 14:02 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
zolilemtumela@gmail.com writes:

> I have a problem with the time format, I can plot but When I am print the time I got a float values. I would like to get time like 16:10 (hh:mm).
> I tried to use strsplit for time but I am not winning. My problem is to be able to do time right.
> Any suggestion will be appreciated! thanks in advance.

Here is how I would do it. I put your example data into a file I named
"time_test.txt".

;*********************************************************** ******
filename = 'time_test.txt'

; Read the data in the file into strings.
rows = File_Lines(filename)
data = StrArr(rows)
OpenR, lun, filename, /Get_Lun
ReadF, lun, data
Free_Lun, lun

; Set up output data arrays.
bx_array = FltArr(rows)
by_array = FltArr(rows)
bz_array = FltArr(rows)
hour = IntArr(rows)
minute = IntArr(rows)

; Parse each row and print it out in the correct format.
FOR j=0,rows-1 DO BEGIN
date = StrMid(data[j], 0, 9)
time = StrMid(data[j], 11, 23)
subString = StrMid(data[j], 24)
ReadS, subString, bx, by, bz
parts = StrSplit(time,':', /Extract)
hour[j] = Fix(parts[0])
minute[j] = Fix(parts[1])
bx_array[j] = bx
by_array[j] = by
bz_array[j] = bz
Print, String(hour[j],Format='(I2.2)') + '.' + $
String(minute[j],Format='(I2.2)'), $
bx_array[j], by_array[j], bz_array[j], $
FORMAT='(A5, 2x, 3(F0.5, 2x))'
ENDFOR

END
;*********************************************************** ******

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: cgimage - two images on the same window ?
Next Topic: Converting days since 0-01-01 to Julian/Gregorian days - how can IDL recognise 0 AD?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 02:07:13 PDT 2025

Total time taken to generate the page: 1.51407 seconds