[Tutor] Sorting specific files by modification date
Kent Johnson
kent37 at tds.net
Tue Nov 6 03:08:35 CET 2007
Fiyawerx wrote:
> first_files = [ file for file in data['xls_files'] if u'First Worksheet'
> in xlrd.open_workbook(file).sheet_names() ]
> data['first_file'] = ??
> This is where I get stuck, I'm trying to figure out how, from the files
> that match, I can select the file with the most current time stamp and
> use that as my main data file.
Something like this:
def fileTime(f):
return os.stat(f).st_mtime
newest = max(first_files, key=fileTime)
Kent
More information about the Tutor
mailing list