blubbblülüllü

This commit is contained in:
Jonas Braus
2024-12-10 19:41:01 +01:00
parent 055657939e
commit c5a8e9c5e3
2 changed files with 53 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import os, pymupdf
def read_files(path, output, filetypes=None):
if filetypes is None:
filetypes = ["pdf", "txt", "png", "jpg", "mp3"]
for root, dirs, files in os.walk(path):
for file in files:
if (file_type := file.split(".")[-1]) in filetypes:
output.append((file_type, os.path.join(path, file)))
for folder in dirs:
read_files(os.path.join(path, folder), output)
break
def extract_pdf_content(pdf_datei):
doc = pymupdf.open(pdf_datei)
a = ""
for page in doc:
a += page.get_text()
return a