Commit 0cb76a00 authored by 张彦钊's avatar 张彦钊

add timely delete csv file

parent 5f50a255
......@@ -109,4 +109,6 @@ if __name__ == "__main__":
end = time.time()
time_cost = (end - start)
print("耗时{}秒".format(time_cost))
# 定期删除预测用户对应的ffm文件
remove_files(DIRECTORY_PATH + "result")
......@@ -3,6 +3,19 @@ import pymysql
import pandas as pd
import numpy as np
import redis
import os
import time
# 定期删除特定文件夹内特征的文件
def remove_files(fileDir):
for eachFile in os.listdir(fileDir):
if (os.path.isfile(fileDir + "/" + eachFile)) and ("DiaryTop3000.csv" in eachFile):
ft = os.stat(fileDir + "/" + eachFile)
ltime = int(ft.st_mtime)
# 删除5分钟前的文件
ntime = int(time.time()) - 5*60
if ltime <= ntime:
os.remove(fileDir + "/" + eachFile)
# 从Tidb数据库的表里获取数据,并转化成df格式
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment