abischoff commited on
Commit
78493d5
·
verified ·
1 Parent(s): 89edaaa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -4,6 +4,7 @@ from transformers import Trainer, AutoTokenizer, XLMRobertaForSequenceClassifica
4
  import torch
5
  import pickle
6
  import re
 
7
 
8
  def checker(content):
9
  #if isinstance(content, bytes):#falls es ein Byte-String ist
@@ -36,7 +37,12 @@ def process_file(file):
36
 
37
  # lese die Datei ein
38
  def read_file(file):
39
- if file:
 
 
 
 
 
40
  with open(file.name, 'r', encoding='utf-8') as f:
41
  content = f.read()
42
  #with open(file.name, 'rb') as f:
 
4
  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
 
37
 
38
  # lese die Datei ein
39
  def read_file(file):
40
+ if ".pdf" in file.name:
41
+ # creating a pdf reader object
42
+ reader = PyPDF2.PdfReader(file.name)
43
+ # print the text of the first page
44
+ print(reader.pages[0].extract_text())
45
+ else:
46
  with open(file.name, 'r', encoding='utf-8') as f:
47
  content = f.read()
48
  #with open(file.name, 'rb') as f: