IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Python知识库 -> 防疫快速汇总 -> 正文阅读

[Python知识库]防疫快速汇总

# 修改了应交增值税  同比下降单位错误的问题
from docx import Document
from docx.shared import Inches

document = Document()

from openpyxl import load_workbook

'''
@File    :
@Author  :  william
@Time    :  2020/09/29
@notice  :  null
@coding  : utf-8
'''
# import xlrd
# from xlutils.copy import copy
import openpyxl

# 下一步还得训练程序
# 使其满足对excel文件名和excel工作薄的识别
# 记得把表格再粘贴下,转成仅值


ws = 0
row_result = 0
column_result = 0
result = 0

#####################################################################锁定资产负债表和工作薄
# 如下代码用于多个相关表的打开操作
fn = '疫情处置工作快报(第25期)附表24时.xlsx'
wb = openpyxl.load_workbook(fn)

ws = wb.get_sheet_by_name('表3三区')
ws02 = wb.get_sheet_by_name('表4济南市隔离点情况统计表')


# print(ws)


def getdate(ws,date_row, date_column, offset):
    # print(date_row)
    # print(date_column)

    for row in ws.iter_rows():
        for cell in row:
            if str(str(cell.value).replace(' ', '')).find(date_row) != -1:
                row_result = cell.row
            # print(row_result)
            else:
                result = 0

                break
    for row in ws.iter_rows():
        for cell in row:
            if str(str(cell.value).replace(' ', '')).find(date_column) != -1:
                column_result = cell.column  +  offset
                #  print(column_result)

                break
    # print(column_result)
    if row_result == 0 or column_result == 0:
        result = 0

    else:
        if ws.cell(row=row_result, column=column_result).value != None:
            # print(column_result)
            result = ws.cell(row=row_result, column=column_result).value
        # print(result)

    return result




if __name__ == '__main__':

    #document.add_heading("财务季报评估报告")





################################

    paragraph01 = document.add_paragraph('封控区')
    paragraph01.add_run("封控区")
    paragraph01.add_run(str(getdate(ws,'合计', '封控区个数',0)))
    paragraph01.add_run("个,涉及")

    fengkongqu_quxian = 0
    if getdate(ws,'历下区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'市中区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'槐荫区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'天桥区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'历城区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'长清区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'章丘区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'济阳区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'莱芜区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'钢城区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'平阴县', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'商河县', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'高新区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'南部山区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    if getdate(ws,'起步区', '封控区个数', 0) > 0:
        fengkongqu_quxian = fengkongqu_quxian + 1
    paragraph01.add_run(str(fengkongqu_quxian))
    paragraph01.add_run("个区、")

    paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 0)))
    paragraph01.add_run("个区、")
    paragraph01.add_run("?")
    paragraph01.add_run("户、")
    paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 1)))
    paragraph01.add_run("人(其中,商河")
    paragraph01.add_run(str(getdate(ws,'商河县', '封控区个数', 0)))
    paragraph01.add_run("个,涉及")
    paragraph01.add_run("?")
    paragraph01.add_run("户、")
    paragraph01.add_run(str(getdate(ws,'商河县', '封控区个数', 1)))
    paragraph01.add_run("人;历城")
    paragraph01.add_run(str(getdate(ws,'历城区', '封控区个数', 0)))
    paragraph01.add_run("个,涉及")
    paragraph01.add_run("?")
    paragraph01.add_run("户、")
    paragraph01.add_run(str(getdate(ws,'历城区', '封控区个数', 1)))
    paragraph01.add_run("人),今日应采检")
    paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 2)))
    paragraph01.add_run("人,已采样")
    paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 3)))
    paragraph01.add_run("人,已出结果")
    paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 4)))
    # 封控区本轮检测结果为阳性的数量:print(getdate(ws,'合计', '封控区个数',4))
    if (getdate(ws,'合计', '封控区个数', 5) == 0):

        paragraph01.add_run("人,均为阴性。")
    else:
        paragraph01.add_run("人,其中阳性")
        paragraph01.add_run(str(getdate(ws,'合计', '封控区个数', 5)))
        paragraph01.add_run("人。")

    ################################

    paragraph02 = document.add_paragraph('管控区')
    paragraph02.add_run("管控区")
    paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 0)))
    paragraph02.add_run("个,涉及")

    guankongqu_quxian = 0
    if getdate(ws,'历下区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'市中区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'槐荫区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'天桥区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'历城区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'长清区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'章丘区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'济阳区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'莱芜区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'钢城区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'平阴县', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'商河县', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'高新区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'南部山区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    if getdate(ws,'起步区', '管控区个数', 0) > 0:
        guankongqu_quxian = guankongqu_quxian + 1
    paragraph02.add_run(str(guankongqu_quxian))
    paragraph02.add_run("个区、")
    paragraph02.add_run("?")
    paragraph02.add_run("户、")
    paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 1)))
    paragraph02.add_run("人(其中,商河")
    paragraph02.add_run(str(getdate(ws,'商河县', '管控区个数', 0)))
    paragraph02.add_run("个,涉及")
    paragraph02.add_run("?")
    paragraph02.add_run("户、")
    paragraph02.add_run(str(getdate(ws,'商河', '管控区个数', 1)))
    paragraph02.add_run("人;历城")
    paragraph02.add_run(str(getdate(ws,'历城区', '管控区个数', 0)))
    paragraph02.add_run("个,涉及")
    paragraph02.add_run("?")
    paragraph02.add_run("户、")
    paragraph02.add_run(str(getdate(ws,'历城区', '管控区个数', 1)))
    paragraph02.add_run("人),今日应采检")
    paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 2)))
    paragraph02.add_run("人,已采样")
    paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 3)))
    paragraph02.add_run("人,已出结果")
    paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 4)))
    # 管控区本轮检测结果为阳性的数量:print(getdate(ws,'合计', '管控区个数',4))
    if (getdate(ws,'合计', '管控区个数', 5) == 0):

        paragraph02.add_run("人,均为阴性。")
    else:
        paragraph02.add_run("人,其中阳性")
        paragraph02.add_run(str(getdate(ws,'合计', '管控区个数', 5)))
        paragraph02.add_run("人。")

    ################################
    paragraph03 = document.add_paragraph('防范区')
  #  paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 0)))
    paragraph03.add_run("个,涉及")

    fangfanqu_quxian = 0
    if getdate(ws,'历下区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'市中区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'槐荫区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'天桥区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'历城区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'长清区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'章丘区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'济阳区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'莱芜区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'钢城区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'平阴县', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'商河县', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'高新区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'南部山区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    if getdate(ws,'起步区', '防范区个数', 0) > 0:
        fangfanqu_quxian = fangfanqu_quxian + 1
    paragraph03.add_run(str(fangfanqu_quxian))

    paragraph03.add_run("个区、")
    paragraph03.add_run("?")
    paragraph03.add_run("户、")
    paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 1)))
    paragraph03.add_run("人,今日应采检")
    paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 2)))
    paragraph03.add_run("人,已采样")
    paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 3)))
    paragraph03.add_run("人,已出结果")
    paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 4)))
    # 防范区本轮检测结果为阳性的数量:print(getdate(ws,'合计', '防范区个数',4))
    if (getdate(ws,'合计', '防范区个数', 5) == 0):

        paragraph03.add_run("人,均为阴性。")
    else:
        paragraph03.add_run("人,其中阳性")
        paragraph03.add_run(str(getdate(ws,'合计', '防范区个数', 5)))
        paragraph03.add_run("人。")

    # paragraph101.add_run('个')


    ################################



    paragraph04 = document.add_paragraph("截至目前,全市现有储备隔离点总数")
    paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 1)))

    paragraph04.add_run("个,房间")
    paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 2)))

    paragraph04.add_run(",其中,已启用隔离点")
    paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 3)))

    paragraph04.add_run("个,房间")
    paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 4)))


    paragraph04.add_run("间,已用房间")

    paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 5)))



    paragraph04.add_run("间,空余房间")
    zongshu = int(getdate(ws02,'济南市', '地区', 4))

    yiyong=  int(getdate(ws02,'济南市', '地区', 5))
    kongyu = 0
    print(zongshu)
    print(yiyong)


    kongyu = zongshu - yiyong
    print(kongyu)

    paragraph04.add_run(str(kongyu))
    paragraph04.add_run("间。空余房间中可即时投入使用的房间")
    paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 6)))

    paragraph04.add_run("间、入境人员备用房间")

    paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 7)))
    paragraph04.add_run("间、其他房间")
    paragraph04.add_run(str(getdate(ws02,'济南市', '地区', 8)))


    paragraph04.add_run("间(正在消杀或因设施维修等原因不能立即投入使用)。")





    document.save('疫情处置快报.docx')
  Python知识库 最新文章
Python中String模块
【Python】 14-CVS文件操作
python的panda库读写文件
使用Nordic的nrf52840实现蓝牙DFU过程
【Python学习记录】numpy数组用法整理
Python学习笔记
python字符串和列表
python如何从txt文件中解析出有效的数据
Python编程从入门到实践自学/3.1-3.2
python变量
上一篇文章      下一篇文章      查看所有文章
加:2022-04-14 23:50:39  更:2022-04-14 23:55:58 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/15 17:25:47-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码