我开发了一个具有 2 个主要功能的 Django 应用:
for file in listOfFiles:
records = []
# read the files = csv from Cyrille python script -> API RedCap
with open(path + file, newline='', encoding="utf8") as csvfile:
has_header = csv.Sniffer().has_header(csvfile.read())
csvfile.seek(0)
spamreader = csv.reader(csvfile, delimiter=',', quotechar='|')
csv_headings = ','.join(next(spamreader))
for row in spamreader:
[positions[0]:positions[1]])
for site in sites:
# get position of site code start and end
positions = getPatientMask(study.id)
if site == row[0][positions[0]:positions[1]]:
records.append(','.join(row))
zip_file.writestr(file, csv_headings+'\n'+'\n'.join(records))
zip_file.close()
在“标准使用”中,导入是使用 celery 的自动编程任务(每天午夜)。 但是一些用户会被授权在需要时进行导入,替换当天的 csv 文件。这种“实时”导入也是使用 celery 任务完成的。
导入可能需要时间,这就是为什么“正常使用”是午夜自动执行的任务。
例如
不知道会不会有问题?大概... 我该如何管理? 感谢帮助