Answers for "python read the last file only in the directory"

0

get last file in directory python

import glob
import os

list_of_files = glob.glob('/path/to/folder/*') # * means all if need specific format then *.csv
latest_file = max(list_of_files, key=os.path.getmtime)
print(latest_file)
Posted by: Guest on September-07-2021
0

get lastest files from directory python

import glob
import os

list_of_files = glob.glob('/path/to/folder/*') # * means all if need specific format then *.csv
latest_file = max(list_of_files, key=os.path.getmtime)
print(latest_file)
Posted by: Guest on December-13-2021

Code answers related to "python read the last file only in the directory"

Python Answers by Framework

Browse Popular Code Answers by Language