400km_t150317_054000
400km_t150317_054100
400km_t150317_054200
The following code reads 141 files and separates the file names into hours, minutes, and seconds.
filenames = [(f).stem for f in ('Path')]
time_array = []
for f in filenames:
parts = f.split('_')
time_string = parts[-1]
time_obj = (time_string, '%H%M%S')
time_array.append(time_obj)
time.struct_time(tm_year=1900, tm_mon=1, tm_mday=1, tm_hour=5, tm_min=40, tm_sec=0, tm_wday=0, tm_yday=1, tm_isdst=-1),
time.struct_time(tm_year=1900, tm_mon=1, tm_mday=1, tm_hour=5, tm_min=41, tm_sec=0, tm_wday=0, tm_yday=1, tm_isdst=-1),
time.struct_time(tm_year=1900, tm_mon=1, tm_mday=1, tm_hour=5, tm_min=42, tm_sec=0, tm_wday=0, tm_yday=1, tm_isdst=-1),
time.struct_time(tm_year=1900, tm_mon=1, tm_mday=1, tm_hour=5, tm_min=43, tm_sec=0, tm_wday=0, tm_yday=1, tm_isdst=-1)
There are 141 outputs the same as the one above. What I want to do is extract the hours, minutes and seconds from 141 outputs and create oneArray,The first output has only hours, minutes and seconds, then the next output, and so on. I want this because I want to get decimal time, hours + (minutes/60) + (seconds/3600). I'll use a decimal hour array in a for loop later.
I know that the code below can extract hours, minutes, seconds correctly from one output, but I don't know how to write such code for all 141 outputs. Below I will show how to work for the first output above.
t = time_array[0]
hour = t.tm_hour
minute = t.tm_min
second = t.tm_sec
print(hour, minute, second)
5 40 0