DDingcheol commited on
Commit
0d627c2
ยท
1 Parent(s): a531e8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -25,6 +25,7 @@ def get_pdf_text(pdf_docs):
25
 
26
  # ๊ณผ์ œ
27
  # ์•„๋ž˜ ํ…์ŠคํŠธ ์ถ”์ถœ ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑ
 
28
  def get_text_file(docs):
29
  text_list = []
30
  try:
@@ -44,7 +45,24 @@ def get_text_file(docs):
44
  print(f"An error occurred while processing files: {ex}")
45
 
46
  return text_list
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
 
48
 
49
  def get_csv_file(docs):
50
  pass
 
25
 
26
  # ๊ณผ์ œ
27
  # ์•„๋ž˜ ํ…์ŠคํŠธ ์ถ”์ถœ ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑ
28
+ '''
29
  def get_text_file(docs):
30
  text_list = []
31
  try:
 
45
  print(f"An error occurred while processing files: {ex}")
46
 
47
  return text_list
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
 
67
  def get_csv_file(docs):
68
  pass