Some fixes. Added csv.

This commit is contained in:
2022-09-22 10:07:14 +02:00
parent cfe2e69125
commit 3e147ae929
13 changed files with 145412 additions and 72 deletions

View File

@@ -1,3 +1,4 @@
from sys import orig_argv
import pandas as pd
from os import listdir
from os.path import isfile, join
@@ -25,6 +26,10 @@ def convert(klinika: str):
if klinika in file and "lock" not in file:
list_paths.append(join(docx_path, file))
for path in list_paths:
viti = file.replace(".docx", "")
viti = viti.split("_")
viti = viti[1]
print(viti)
document = Document(path)
for table in document.tables:
if "urgjenca_2016.docx" in path:
@@ -37,17 +42,20 @@ def convert(klinika: str):
for cell in table.rows[0].cells:
columns.append(cell.text.strip().replace('\n', ' '))
columns.append('VITI')
RowA = table.rows[0]
table_element = table._tbl
table_element.remove(RowA._tr)
for row in table.rows:
text = [cell.text for cell in row.cells]
text.append(viti)
df = df.append([text], ignore_index=True)
print(f"Mbaroi {path} me {datetime.now()}")
for word in columns:
if word not in filtered_columns:
filtered_columns.append(word)
print(filtered_columns)
print(f'{len(filtered_columns)} Columns found')
print('writing to excel...')
print(f"Perfundoi {klinika} me {datetime.now()}")