tjxj commited on
Commit
97508c1
·
1 Parent(s): 0cf52a1

Add application file

Browse files
.history/app_20220620150937.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #-*- coding : utf-8-*-
2
+ import pandas as pd
3
+ import streamlit as st
4
+ import base64
5
+ import subprocess # process in the os
6
+ from subprocess import STDOUT #os process manipuation
7
+ import os
8
+
9
+ @st.cache
10
+ def gh():
11
+ """install ghostscript on the linux machine"""
12
+ proc = subprocess.Popen('apt-get install -y ghostscript', shell=True, stdin=None, stdout=open(os.devnull,"wb"), stderr=STDOUT, executable="/bin/bash")
13
+ proc.wait()
14
+
15
+ gh()
16
+ import camelot as cam # extracting tables from PDFs
17
+
18
+ st.title("PDF Table Extractor")
19
+
20
+ input_pdf = st.file_uploader(label = "", type = 'pdf')
21
+
22
+ page_number = st.text_input("请填写表格所在PDF页码,eg: 3", value = 1)
23
+
24
+ if input_pdf is not None:
25
+ # byte object into a PDF file
26
+ with open("input.pdf", "wb") as f:
27
+ base64_pdf = base64.b64encode(input_pdf.read()).decode('utf-8')
28
+ f.write(base64.b64decode(base64_pdf))
29
+ f.close()
30
+
31
+ # read the pdf and parse it using stream
32
+ tables = cam.read_pdf("input.pdf", pages=page_number)
33
+ result = pd.ExcelWriter('result.xlsx', engine='xlsxwriter')
34
+ tables[0].to_excel(result,index=False)
35
+ # for i in range(0,len(tables)):
36
+ # table = tables[i].df
37
+ # sheetname = str(i)
38
+ # table.to_excel(result, sheetname,index=False)
39
+
40
+ with open('result.xlsx','rb') as f:
41
+ st.download_button('提取完成,点击下载!', f,file_name='result.xlsx',mime="application/vnd.ms-excel")
.history/app_20220620150946.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #-*- coding : utf-8-*-
2
+ import pandas as pd
3
+ import streamlit as st
4
+ import base64
5
+ import subprocess # process in the os
6
+ from subprocess import STDOUT #os process manipuation
7
+ import os
8
+
9
+ @st.cache
10
+ def gh():
11
+ """install ghostscript on the linux machine"""
12
+ proc = subprocess.Popen('apt-get install -y ghostscript', shell=True, stdin=None, stdout=open(os.devnull,"wb"), stderr=STDOUT, executable="/bin/bash")
13
+ proc.wait()
14
+
15
+ gh()
16
+
17
+ import camelot as cam # extracting tables from PDFs
18
+
19
+ st.title("PDF Table Extractor")
20
+
21
+ input_pdf = st.file_uploader(label = "", type = 'pdf')
22
+
23
+ page_number = st.text_input("请填写表格所在PDF页码,eg: 3", value = 1)
24
+
25
+ if input_pdf is not None:
26
+ # byte object into a PDF file
27
+ with open("input.pdf", "wb") as f:
28
+ base64_pdf = base64.b64encode(input_pdf.read()).decode('utf-8')
29
+ f.write(base64.b64decode(base64_pdf))
30
+ f.close()
31
+
32
+ # read the pdf and parse it using stream
33
+ tables = cam.read_pdf("input.pdf", pages=page_number)
34
+ result = pd.ExcelWriter('result.xlsx', engine='xlsxwriter')
35
+ tables[0].to_excel(result,index=False)
36
+ # for i in range(0,len(tables)):
37
+ # table = tables[i].df
38
+ # sheetname = str(i)
39
+ # table.to_excel(result, sheetname,index=False)
40
+
41
+ with open('result.xlsx','rb') as f:
42
+ st.download_button('提取完成,点击下载!', f,file_name='result.xlsx',mime="application/vnd.ms-excel")
.history/app_20220620151019.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #-*- coding : utf-8-*-
2
+ import pandas as pd
3
+ import streamlit as st
4
+ import os,base64,subprocess
5
+ from subprocess import STDOUT #os process manipuation
6
+
7
+ @st.cache
8
+ def gh():
9
+ """install ghostscript on the linux machine"""
10
+ proc = subprocess.Popen('apt-get install -y ghostscript', shell=True, stdin=None, stdout=open(os.devnull,"wb"), stderr=STDOUT, executable="/bin/bash")
11
+ proc.wait()
12
+
13
+ gh()
14
+
15
+ import camelot as cam # extracting tables from PDFs
16
+
17
+ st.title("PDF Table Extractor")
18
+
19
+ input_pdf = st.file_uploader(label = "", type = 'pdf')
20
+
21
+ page_number = st.text_input("请填写表格所在PDF页码,eg: 3", value = 1)
22
+
23
+ if input_pdf is not None:
24
+ # byte object into a PDF file
25
+ with open("input.pdf", "wb") as f:
26
+ base64_pdf = base64.b64encode(input_pdf.read()).decode('utf-8')
27
+ f.write(base64.b64decode(base64_pdf))
28
+ f.close()
29
+
30
+ # read the pdf and parse it using stream
31
+ tables = cam.read_pdf("input.pdf", pages=page_number)
32
+ result = pd.ExcelWriter('result.xlsx', engine='xlsxwriter')
33
+ tables[0].to_excel(result,index=False)
34
+ # for i in range(0,len(tables)):
35
+ # table = tables[i].df
36
+ # sheetname = str(i)
37
+ # table.to_excel(result, sheetname,index=False)
38
+
39
+ with open('result.xlsx','rb') as f:
40
+ st.download_button('提取完成,点击下载!', f,file_name='result.xlsx',mime="application/vnd.ms-excel")
.history/app_20220620151024.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #-*- coding : utf-8-*-
2
+ import pandas as pd
3
+ import streamlit as st
4
+ import os,base64,subprocess
5
+ from subprocess import STDOUT #os process manipuation
6
+
7
+ @st.cache
8
+ def gh():
9
+ """install ghostscript on the linux machine"""
10
+ proc = subprocess.Popen('apt-get install -y ghostscript', shell=True, stdin=None, stdout=open(os.devnull,"wb"), stderr=STDOUT, executable="/bin/bash")
11
+ proc.wait()
12
+
13
+ gh()
14
+
15
+ import camelot as cam
16
+
17
+ st.title("PDF Table Extractor")
18
+
19
+ input_pdf = st.file_uploader(label = "", type = 'pdf')
20
+
21
+ page_number = st.text_input("请填写表格所在PDF页码,eg: 3", value = 1)
22
+
23
+ if input_pdf is not None:
24
+ # byte object into a PDF file
25
+ with open("input.pdf", "wb") as f:
26
+ base64_pdf = base64.b64encode(input_pdf.read()).decode('utf-8')
27
+ f.write(base64.b64decode(base64_pdf))
28
+ f.close()
29
+
30
+ # read the pdf and parse it using stream
31
+ tables = cam.read_pdf("input.pdf", pages=page_number)
32
+ result = pd.ExcelWriter('result.xlsx', engine='xlsxwriter')
33
+ tables[0].to_excel(result,index=False)
34
+ # for i in range(0,len(tables)):
35
+ # table = tables[i].df
36
+ # sheetname = str(i)
37
+ # table.to_excel(result, sheetname,index=False)
38
+
39
+ with open('result.xlsx','rb') as f:
40
+ st.download_button('提取完成,点击下载!', f,file_name='result.xlsx',mime="application/vnd.ms-excel")
.history/app_20220620151031.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #-*- coding : utf-8-*-
2
+ import pandas as pd
3
+ import streamlit as st
4
+ import os,base64,subprocess
5
+ from subprocess import STDOUT #os process manipuation
6
+
7
+ @st.cache
8
+ def gh():
9
+ """install ghostscript on the linux machine"""
10
+ proc = subprocess.Popen('apt-get install -y ghostscript', shell=True, stdin=None, stdout=open(os.devnull,"wb"), stderr=STDOUT, executable="/bin/bash")
11
+ proc.wait()
12
+
13
+ gh()
14
+
15
+ import camelot as cam
16
+
17
+ st.title("PDF Table Extractor")
18
+
19
+ input_pdf = st.file_uploader(label = "", type = 'pdf')
20
+
21
+ page_number = st.text_input("请填写表格所在PDF页码,eg: 3", value = 1)
22
+
23
+ if input_pdf is not None:
24
+ # byte object into a PDF file
25
+ with open("input.pdf", "wb") as f:
26
+ base64_pdf = base64.b64encode(input_pdf.read()).decode('utf-8')
27
+ f.write(base64.b64decode(base64_pdf))
28
+ f.close()
29
+
30
+ # read the pdf and parse it using stream
31
+ tables = cam.read_pdf("input.pdf", pages=page_number)
32
+ result = pd.ExcelWriter('result.xlsx', engine='xlsxwriter')
33
+ tables[0].to_excel(result,index=False)
34
+ # for i in range(0,len(tables)):
35
+ # table = tables[i].df
36
+ # sheetname = str(i)
37
+ # table.to_excel(result, sheetname,index=False)
38
+
39
+ with open('result.xlsx','rb') as f:
40
+ st.download_button('提取完成,点击下载!', f,file_name='result.xlsx',mime="application/vnd.ms-excel")
.history/app_20220620151050.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #-*- coding : utf-8-*-
2
+ import pandas as pd
3
+ import streamlit as st
4
+ import os,base64,subprocess
5
+ from subprocess import STDOUT #os process manipuation
6
+
7
+ @st.cache
8
+ def gh():
9
+ """install ghostscript on the linux machine"""
10
+ proc = subprocess.Popen('apt-get install -y ghostscript', shell=True, stdin=None, stdout=open(os.devnull,"wb"), stderr=STDOUT, executable="/bin/bash")
11
+ proc.wait()
12
+
13
+ gh()
14
+
15
+ import camelot as cam
16
+
17
+ st.title("PDF Table Extractor")
18
+
19
+ input_pdf = st.file_uploader(label = "", type = 'pdf')
20
+
21
+ page_number = st.text_input("请填写表格所在PDF页码,eg: 3", value = 1)
22
+
23
+ if input_pdf is not None:
24
+ # byte object into a PDF file
25
+ with open("input.pdf", "wb") as f:
26
+ base64_pdf = base64.b64encode(input_pdf.read()).decode('utf-8')
27
+ f.write(base64.b64decode(base64_pdf))
28
+ f.close()
29
+
30
+ # read the pdf and parse it using stream
31
+ tables = cam.read_pdf("input.pdf", pages=page_number)
32
+ result = pd.ExcelWriter('result.xlsx', engine='xlsxwriter')
33
+ tables[0].to_excel(result,index=False)
34
+ # for i in range(0,len(tables)):
35
+ # table = tables[i].df
36
+ # sheetname = str(i)
37
+ # table.to_excel(result, sheetname,index=False)
38
+
39
+ with open('result.xlsx','rb') as f:
40
+ st.download_button('提取完成,点击下载!', f,file_name='result.xlsx',mime="application/vnd.ms-excel")
app.py CHANGED
@@ -1,11 +1,8 @@
1
  #-*- coding : utf-8-*-
2
-
3
  import pandas as pd
4
  import streamlit as st
5
- import base64
6
- import subprocess # process in the os
7
  from subprocess import STDOUT #os process manipuation
8
- import os
9
 
10
  @st.cache
11
  def gh():
@@ -14,7 +11,8 @@ def gh():
14
  proc.wait()
15
 
16
  gh()
17
- import camelot as cam # extracting tables from PDFs
 
18
 
19
  st.title("PDF Table Extractor")
20
 
 
1
  #-*- coding : utf-8-*-
 
2
  import pandas as pd
3
  import streamlit as st
4
+ import os,base64,subprocess
 
5
  from subprocess import STDOUT #os process manipuation
 
6
 
7
  @st.cache
8
  def gh():
 
11
  proc.wait()
12
 
13
  gh()
14
+
15
+ import camelot as cam
16
 
17
  st.title("PDF Table Extractor")
18