|
import streamlit as st |
|
from docx import Document |
|
import pandas as pd |
|
|
|
# OS = st.sidebar.multiselect("请选择操作系统", ['Linux', 'AIX(待开发)', 'Solaris(待开发)','hpux(待开发)','Window(待开发)'], key="OS") |
|
# print(OS) |
|
# uploaded_file = st.sidebar.file_uploader("请选择源文件所在文件夹",accept_multiple_files = True) |
|
# #测试用 |
|
# uploaded_file1 = st.sidebar.file_uploader("底稿模板") |
|
path = st.sidebar.text_input('模板路径') |
|
# |
|
# if uploaded_file is not None: |
|
# # To read file as bytes: |
|
# # print(uploaded_file) |
|
# a = '' |
|
# for f in uploaded_file: |
|
# info = f.getvalue().decode("utf-8") |
|
# print(info) |
|
# a = a + info |
|
# # print(a) |
|
# |
|
# if uploaded_file1 is not None: |
|
# workingpaper = docx.Document(uploaded_file1) |
|
# table = workingpaper.tables[1] |
|
# st.table(table) |
|
# a =r'C:\Users\Cris SF He\PycharmProjects\PWC\venv\OS security review (Linux).docx' |
|
if path is not None: |
|
work = Document(path) |
|
table = work.tables[1] |
|
len1 = len(table.rows) |
|
|
|
a = [] |
|
for i in range(0,6): |
|
a.append(table.cell(0,i).text) |
|
a = tuple(a) |
|
print(a) |
|
df = pd.DataFrame(columns=a,dtype=object) |
|
print(df) |
|
|
|
for i,j in enumerate(a): |
|
listco = [] |
|
for k in range(1,len1): |
|
listco.append(table.cell(k,i).text) |
|
# print(listco) |
|
df[j] = listco |
|
|
|
st.table(df) |
|
|