abischoff commited on
Commit
6b02477
·
verified ·
1 Parent(s): 30d7363

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -5,6 +5,7 @@ import torch
5
  import pickle
6
  import re
7
  import PyPDF2
 
8
 
9
  def checker(content):
10
  #if isinstance(content, bytes):#falls es ein Byte-String ist
@@ -46,11 +47,16 @@ def read_file(file):
46
  while counter < len(reader.pages):
47
  content += reader.pages[counter].extract_text()
48
  counter += 1
 
 
 
 
49
  else:
50
  with open(file.name, 'r', encoding='utf-8') as f:
51
  content = f.read()
52
  #with open(file.name, 'rb') as f:
53
  # content = pickle.load(f)
 
54
  return content
55
 
56
  def is_valid_file(file_path: str, file_types: list[str]) -> bool:
 
5
  import pickle
6
  import re
7
  import PyPDF2
8
+ import docx
9
 
10
  def checker(content):
11
  #if isinstance(content, bytes):#falls es ein Byte-String ist
 
47
  while counter < len(reader.pages):
48
  content += reader.pages[counter].extract_text()
49
  counter += 1
50
+ if ".docx" in file.name:
51
+ doc = docx.Document(filename)
52
+ for para in doc.paragraphs:
53
+ content += para.text
54
  else:
55
  with open(file.name, 'r', encoding='utf-8') as f:
56
  content = f.read()
57
  #with open(file.name, 'rb') as f:
58
  # content = pickle.load(f)
59
+ print(content)
60
  return content
61
 
62
  def is_valid_file(file_path: str, file_types: list[str]) -> bool: