From 3dd6ca0e5fe784b0278da49545cb68f26c9ee974 Mon Sep 17 00:00:00 2001 From: TA Date: Thu, 12 Nov 2020 02:31:50 +0800 Subject: [PATCH] script for dumping sheet --- dump_sheet.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 dump_sheet.py diff --git a/dump_sheet.py b/dump_sheet.py new file mode 100644 index 0000000..111cca5 --- /dev/null +++ b/dump_sheet.py @@ -0,0 +1,17 @@ +# coding: utf-8 +from openpyxl import Workbook +from app import * + +wb = Workbook() +ws = wb.active + +ws.title = '提名' +ws.append(['编号', '是否正式提名', '赞数', '字数']) +candidates = Candidate.query.all() +for candidate in candidates: + ws.append([candidate.id, + (candidate.id == 68) or (len(candidate.private) > 0 and candidate.id not in {3, 9, 62}), + Like.query.filter_by(cid = candidate.id).count(), + len(candidate.content)]) + +wb.save('nominations.xlsx')