Crissf commited on
Commit
6b646f8
·
1 Parent(s): 3f0a80b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from docx import Document
3
+ import pandas as pd
4
+
5
+ # OS = st.sidebar.multiselect("请选择操作系统", ['Linux', 'AIX(待开发)', 'Solaris(待开发)','hpux(待开发)','Window(待开发)'], key="OS")
6
+ # print(OS)
7
+ # uploaded_file = st.sidebar.file_uploader("请选择源文件所在文件夹",accept_multiple_files = True)
8
+ # #测试用
9
+ # uploaded_file1 = st.sidebar.file_uploader("底稿模板")
10
+ path = st.sidebar.text_input('模板路径')
11
+ #
12
+ # if uploaded_file is not None:
13
+ # # To read file as bytes:
14
+ # # print(uploaded_file)
15
+ # a = ''
16
+ # for f in uploaded_file:
17
+ # info = f.getvalue().decode("utf-8")
18
+ # print(info)
19
+ # a = a + info
20
+ # # print(a)
21
+ #
22
+ # if uploaded_file1 is not None:
23
+ # workingpaper = docx.Document(uploaded_file1)
24
+ # table = workingpaper.tables[1]
25
+ # st.table(table)
26
+ # a =r'C:\Users\Cris SF He\PycharmProjects\PWC\venv\OS security review (Linux).docx'
27
+ if path is not None:
28
+ work = Document(path)
29
+ table = work.tables[1]
30
+ len1 = len(table.rows)
31
+
32
+ a = []
33
+ for i in range(0,6):
34
+ a.append(table.cell(0,i).text)
35
+ a = tuple(a)
36
+ print(a)
37
+ df = pd.DataFrame(columns=a,dtype=object)
38
+ print(df)
39
+
40
+ for i,j in enumerate(a):
41
+ listco = []
42
+ for k in range(1,len1):
43
+ listco.append(table.cell(k,i).text)
44
+ # print(listco)
45
+ df[j] = listco
46
+
47
+ st.table(df)