Python: Taking an array and break it into subarrays based on some criteria

Posted by randombits on Stack Overflow See other posts from Stack Overflow or by randombits
Published on 2010-04-01T22:04:49Z Indexed on 2010/04/01 22:13 UTC
Read the original article Hit count: 243

Filed under:

I have an array of files. I'd like to be able to break that array down into one array with multiple subarrays, each subarray contains files that were created on the same day. So right now if the array contains files from March 1 - March 31, I'd like to have an array with 31 subarrays (assuming there is at least > 1 file for each day).

In the long run, I'm trying to find the file from each day with the latest creation/modification time. If there is a way to bundle that into the iterations that are required above to save some CPU cycles, that would be even more ideal. Then I'd have one flat array with 31 files, one for each day, for the latest file created on each individual day.

© Stack Overflow or respective owner

Related posts about python