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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -27,13 +27,14 @@ def get_pdf_text(pdf_docs):
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):
 
27
  def get_text_file(docs):
28
  text_list = []
29
  for doc in docs:
30
+ # 파일 객체λ₯Ό μ²˜λ¦¬ν•©λ‹ˆλ‹€.
31
+ if hasattr(doc, 'read'): # 파일 객체에 'read' λ©”μ„œλ“œκ°€ μžˆλŠ”μ§€ ν™•μΈν•©λ‹ˆλ‹€.
32
+ text = doc.read().decode("utf-8") # νŒŒμΌμ„ 읽고 UTF-8둜 λ””μ½”λ”©ν•˜μ—¬ λ¬Έμžμ—΄λ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
33
  else:
34
+ text = str(doc) # 파일 객체가 μ•„λ‹Œ 경우 λ¬Έμžμ—΄λ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
35
  text_list.append(text)
36
  return text_list
37
+
38
 
39
 
40
  def get_csv_file(docs):