DDingcheol commited on
Commit
96060c4
ยท
1 Parent(s): 6edfa7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -37,12 +37,12 @@ def get_text_file(docs):
37
  text_list.append(text)
38
 
39
  # ์ฃผ์–ด์ง„ ํŒŒ์ผ ๋ชฉ๋ก์„ ๋ฐ˜๋ณตํ•˜๋ฉด์„œ ๊ฐ ํŒŒ์ผ์„ ์ฒ˜๋ฆฌ
40
- for doc in docs:
41
- if isinstance(doc, tuple) and len(doc) == 2:
42
- filename, file_content = doc
43
- if filename.lower().endswith('.txt'): # ํŒŒ์ผ ํ™•์žฅ์ž ํ™•์ธ
44
- bytes_file = BytesIO(file_content.encode()) # BytesIO๋กœ ๋ณ€ํ™˜
45
- process_txt_file(bytes_file.getvalue()) # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜ ํ˜ธ์ถœ
46
 
47
  # ๋‹ค๋ฅธ ํŒŒ์ผ ์œ ํ˜•(PDF, CSV, JSON ๋“ฑ)์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ
48
  # ํ•„์š”ํ•˜๋‹ค๋ฉด ์—ฌ๊ธฐ์— ์ถ”๊ฐ€์ ์ธ ํŒŒ์ผ ์ฒ˜๋ฆฌ ๋กœ์ง์„ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
@@ -51,7 +51,6 @@ def get_text_file(docs):
51
 
52
 
53
 
54
-
55
  def get_csv_file(docs):
56
  text_list = []
57
  for doc in docs:
 
37
  text_list.append(text)
38
 
39
  # ์ฃผ์–ด์ง„ ํŒŒ์ผ ๋ชฉ๋ก์„ ๋ฐ˜๋ณตํ•˜๋ฉด์„œ ๊ฐ ํŒŒ์ผ์„ ์ฒ˜๋ฆฌ
40
+ for file_content in docs:
41
+ try:
42
+ file_content.decode("utf-8") # ํŒŒ์ผ ๋‚ด์šฉ์ด ์œ ์š”ํ•œ์ง€ ํ™•์ธ
43
+ process_txt_file(file_content) # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜ ํ˜ธ์ถœ
44
+ except Exception as e:
45
+ pass # ํ…์ŠคํŠธ๊ฐ€ ์•„๋‹Œ ํŒŒ์ผ์€ ๊ฑด๋„ˆ๋œ๋‹ˆ๋‹ค.
46
 
47
  # ๋‹ค๋ฅธ ํŒŒ์ผ ์œ ํ˜•(PDF, CSV, JSON ๋“ฑ)์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ
48
  # ํ•„์š”ํ•˜๋‹ค๋ฉด ์—ฌ๊ธฐ์— ์ถ”๊ฐ€์ ์ธ ํŒŒ์ผ ์ฒ˜๋ฆฌ ๋กœ์ง์„ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
 
51
 
52
 
53
 
 
54
  def get_csv_file(docs):
55
  text_list = []
56
  for doc in docs: