flucoe
August 30th, 2012, 10:28 PM
Hi,
I have a folder with hundreds of text files with filenames of the form hhmmSkz.txt were hh and mm correspond to the hour and minute in which the file was generated and S is the string part of the name that has elements k and z that change from file to file.
I need to put together all the files that correspond to the same hour. In a previous part of this work I was generating these files once per hour so I have the code to open files with different S. However, now I need to open the files with the same component hh, no matter what mm is, and I really have no idea how to do it.
In the previous part S had some numerical elements so I was doing the following
for k in range(1,16):
for z in range(1,7):
for line in open('R/S'+str(k)+'-'+str(z)+'.txt','r'):
If I'm interested in something such as hh being 05 I would like to have something such as the code above but that doesn't consider the mm part of the filename.
Any ideas? Thanks!
I have a folder with hundreds of text files with filenames of the form hhmmSkz.txt were hh and mm correspond to the hour and minute in which the file was generated and S is the string part of the name that has elements k and z that change from file to file.
I need to put together all the files that correspond to the same hour. In a previous part of this work I was generating these files once per hour so I have the code to open files with different S. However, now I need to open the files with the same component hh, no matter what mm is, and I really have no idea how to do it.
In the previous part S had some numerical elements so I was doing the following
for k in range(1,16):
for z in range(1,7):
for line in open('R/S'+str(k)+'-'+str(z)+'.txt','r'):
If I'm interested in something such as hh being 05 I would like to have something such as the code above but that doesn't consider the mm part of the filename.
Any ideas? Thanks!