Last active
October 13, 2015 04:50
-
-
Save kurozumi/5550b5ef60660b3fcbe3 to your computer and use it in GitHub Desktop.
【Python】ディレクトリ内で最も古いCSVファイルを削除する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from glob import glob | |
path = "dir/*.csv" | |
files = glob(path) | |
if len(files) > 0: | |
files.sort(cmp=lambda x, y: int(os.path.getctime(x) - os.path.getctime(y))) | |
os.remove(files[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment