DDingcheol commited on
Commit
8c8e598
Β·
1 Parent(s): d51d064

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -27,9 +27,14 @@ def get_pdf_text(pdf_docs):
27
  def get_text_file(docs):
28
  text_list = []
29
  for doc in docs:
30
- text = doc.getvalue().decode("utf-8") # bytes ν˜•μ‹μ˜ 데이터λ₯Ό λ¬Έμžμ—΄λ‘œ λ””μ½”λ”©ν•©λ‹ˆλ‹€.
 
 
 
 
31
  text_list.append(text)
32
- return text_list
 
33
 
34
  def get_csv_file(docs):
35
  pass
 
27
  def get_text_file(docs):
28
  text_list = []
29
  for doc in docs:
30
+ # 파일의 νƒ€μž…μ„ ν™•μΈν•˜μ—¬ μ²˜λ¦¬ν•©λ‹ˆλ‹€.
31
+ if isinstance(doc, bytes):
32
+ text = doc.decode("utf-8") # bytes 객체인 경우 λ””μ½”λ”©ν•˜μ—¬ λ¬Έμžμ—΄λ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
33
+ else:
34
+ text = doc.read().decode("utf-8") # 파일 객체인 경우 read() λ©”μ„œλ“œλ₯Ό μ‚¬μš©ν•˜μ—¬ 읽고 λ””μ½”λ”©ν•©λ‹ˆλ‹€.
35
  text_list.append(text)
36
+ return text_list
37
+
38
 
39
  def get_csv_file(docs):
40
  pass