Skip to content

Instantly share code, notes, and snippets.

@nchelaru
Created July 9, 2020 02:45
Show Gist options
  • Save nchelaru/d7d2d3b76d329f351644550010387cc8 to your computer and use it in GitHub Desktop.
Save nchelaru/d7d2d3b76d329f351644550010387cc8 to your computer and use it in GitHub Desktop.
To get the latest version of a file within a directory.
import glob
import os
list_of_files = glob.glob('/path/to/folder/filename_*.csv')
latest_file = max(list_of_files, key=os.path.getmtime)
print latest_file
@nchelaru
Copy link
Author

nchelaru commented Jul 9, 2020

Modified from StackOverflow answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment