-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (33 loc) · 1016 Bytes
/
main.py
File metadata and controls
44 lines (33 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from pdfpart import *
from parser import *
from operate_and_write import *
import platform
def open_file(file):
if platform.system() == 'Linux':
os.system(f'xdg-open {file}')
elif platform.system() == 'Windows':
os.startfile(file)
def create_dirs():
"""if not exists, creates folder for raw, intermediate xlsx-files converted
via API("rawxl") and folder for final xlsx files ("out")"""
try:
os.makedirs('out/')
os.makedirs('rawxl/')
except:
pass
def convert_file(source_pdf):
source_xl = convert_pdf_to_xlsl(source_pdf, './rawxl/')
retrieved_data = parse(f'./rawxl/{source_xl}')
calculated_data = calc_packings(retrieved_data)
output_xl = write_results(sample_file='sample.xlsx',
outp_filename=f'./out/{source_xl}',
parsed=retrieved_data,
calculated=calculated_data)
return output_xl
def main():
source_pdf = input('filename or path: ')
converted_file = convert_file(source_pdf)
open_file(f'{converted_file}')
if __name__ == '__main__':
create_dirs()
main()