Looks like someone ate it! I reloaded the submission.
Good thing I checked the comments! Thanks ...
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
hi I am doing something very similar what i want is to be able to pull the 6 latest modified / original file like so ...
ex1.txt = 28/06/10
ex2.txt = 27/06/10
ex3.txt = 24/06/10
ex4.txt = 19/06/10
I am using the same code as above with a few tweaks for other operations i need to do in this program
at the moment i get the 6 latest files but some of them have the same date i need to get the latest files but only 1 per date
this is what i get atm
ex1.txt = 28/06/10
ex2.txt = 28/06/10
ex3.txt = 28/06/10
ex4.txt = 17/06/10
ex5.txt = 17/06/10
ex6.txt = 16/06/10
danholding
Junior Poster in Training
56 posts since Aug 2010
Reputation Points: 15
Solved Threads: 1
You can add this code to the end of the snippet code ...
print('-'*60)
# optional, count files with matching dates
date_name_list = []
for file in date_file_list:
# extract just the filename
folder, file_name = os.path.split(file[1])
# convert date tuple to MM/DD/YYYY date format
file_date = time.strftime("%m/%d/%y", file[0])
date_name_list.append((file_date, file_name))
# contains date:count pairs
date_count_dict = {}
# contains date:[files] pairs
date_name_dict = {}
for date, name in date_name_list:
# word_freq[word] = word_freq.get(word, 0) + 1
date_count_dict[date] = date_count_dict.get(date, 0) +1
date_name_dict.setdefault(date, []).append(name)
import pprint
print("Files with the same date:")
pprint.pprint(date_name_dict)
print('-'*60)
print("Same dates count:")
pprint.pprint(date_count_dict)
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417