DDingcheol commited on
Commit
6974986
Β·
1 Parent(s): 0d627c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -13
app.py CHANGED
@@ -48,19 +48,14 @@ def get_text_file(docs):
48
  '''
49
  def get_text_file(docs):
50
  text_list = []
51
- for file in docs:
52
- if file.type == 'text/plain':
53
- try:
54
- # 파일이 .txt인 경우
55
- text = file.getvalue().decode("utf-8") # 파일 λ‚΄μš©μ„ utf-8 ν˜•μ‹μœΌλ‘œ λ””μ½”λ”©ν•˜μ—¬ ν…μŠ€νŠΈλ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
56
- text_list.append(text)
57
- except UnicodeDecodeError as decode_error:
58
- print(f"UnicodeDecodeError occurred while decoding text: {decode_error}")
59
- # νŒŒμΌμ„ λ‹€λ₯Έ λ°©μ‹μœΌλ‘œ λ””μ½”λ”©ν•˜κ±°λ‚˜ κ±΄λ„ˆλ›°λ„λ‘ μ²˜λ¦¬ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
60
- continue
61
- except Exception as e:
62
- print(f"An error occurred while extracting text: {e}")
63
- continue # λ‹€λ₯Έ μ˜ˆμ™Έκ°€ λ°œμƒν•˜λ©΄ κ±΄λ„ˆλœλ‹ˆλ‹€.
64
 
65
  return text_list
66
 
 
48
  '''
49
  def get_text_file(docs):
50
  text_list = []
51
+ try:
52
+ text = docs.getvalue().decode("utf-8") # 파일 λ‚΄μš©μ„ utf-8 ν˜•μ‹μœΌλ‘œ λ””μ½”λ”©ν•˜μ—¬ ν…μŠ€νŠΈλ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
53
+ text_list.append(text)
54
+ except UnicodeDecodeError as decode_error:
55
+ print(f"UnicodeDecodeError occurred while decoding text: {decode_error}")
56
+ # νŒŒμΌμ„ λ‹€λ₯Έ λ°©μ‹μœΌλ‘œ λ””μ½”λ”©ν•˜κ±°λ‚˜ κ±΄λ„ˆλ›°λ„λ‘ μ²˜λ¦¬ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
57
+ except Exception as e:
58
+ print(f"An error occurred while extracting text: {e}")
 
 
 
 
 
59
 
60
  return text_list
61