Move Projekt-KIQ-HP bahn/ -> dhive/ (dhive project); add steering files

This commit is contained in:
2026-06-30 21:15:59 +02:00
parent d9291f53e4
commit b0e452708a
124 changed files with 74 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import os
import glob
from pypdf import PdfReader
from docx import Document
os.makedirs('extracted_text', exist_ok=True)
for filepath in glob.glob('source_Data/*.*'):
filename = os.path.basename(filepath)
output_path = f'extracted_text/{filename}.txt'
print(f'Extracting {filename}...')
try:
if filename.endswith('.pdf'):
reader = PdfReader(filepath)
text = ''
for page in reader.pages:
text += page.extract_text() + '\n'
with open(output_path, 'w', encoding='utf-8') as f:
f.write(text)
elif filename.endswith('.docx'):
doc = Document(filepath)
text = '\n'.join([p.text for p in doc.paragraphs])
with open(output_path, 'w', encoding='utf-8') as f:
f.write(text)
except Exception as e:
print(f"Error parsing {filename}: {e}")
print("Done extracting!")