Re: [Tutor] Sorting specific files by modification date

2007-11-05 Thread Kent Johnson
Fiyawerx wrote: > Thanks Kent, thats just what I needed, but got stuck in a single mode of > thought trying to do it inline, didn't even think of adding a separate > function since the program seemed 'too simple'. You can always use a lambda if you like that style: newest = max(first_files, key=

Re: [Tutor] Sorting specific files by modification date

2007-11-05 Thread Kent Johnson
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 t

Re: [Tutor] Sorting specific files by modification date

2007-11-05 Thread Michael Langford
In psudocode: #map the files to their time. filesByTimes = {} for each in filesInDirectory: filesByTimes[os.stat(each).st_mtime]=each #find the largest time times = filesByTimes.keys() sort(times) #retrieve the file that goes with it latestFile = filesByTimes[times[-1]] --Michael On

[Tutor] Sorting specific files by modification date

2007-11-05 Thread Fiyawerx
I'm working on a small script that so far, using the xlrd module, ( http://www.lexicon.net/sjmachin/xlrd.html) will parse all the files in a given directory for a xls file with a specific worksheet. This way, if the file names change, or people don't save the spreadsheet with the right name, my scr