DDingcheol commited on
Commit
009d12e
ยท
1 Parent(s): a04e0a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -32,15 +32,14 @@ def get_text_file(docs):
32
  text_list = []
33
 
34
  # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜
35
- def process_txt_file(filename, file_content):
36
- file_extension = filename.split('.')[-1].lower() # ํŒŒ์ผ ์ด๋ฆ„์—์„œ ํ™•์žฅ์ž ์ถ”์ถœ
37
- if file_extension == 'txt': # ์ถ”์ถœํ•œ ํ™•์žฅ์ž๊ฐ€ 'txt'์ธ์ง€ ํ™•์ธ
38
- text = file_content.decode("utf-8")
39
- text_list.append(text)
40
 
41
  # ์ฃผ์–ด์ง„ ํŒŒ์ผ ๋ชฉ๋ก์„ ๋ฐ˜๋ณตํ•˜๋ฉด์„œ ๊ฐ ํŒŒ์ผ์„ ์ฒ˜๋ฆฌ
42
- for filename, doc in docs:
43
- process_txt_file(filename, doc) # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜ ํ˜ธ์ถœ
 
44
 
45
  # ๋‹ค๋ฅธ ํŒŒ์ผ ์œ ํ˜•(PDF, CSV, JSON ๋“ฑ)์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ
46
  # ํ•„์š”ํ•˜๋‹ค๋ฉด ์—ฌ๊ธฐ์— ์ถ”๊ฐ€์ ์ธ ํŒŒ์ผ ์ฒ˜๋ฆฌ ๋กœ์ง์„ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
@@ -49,6 +48,7 @@ def get_text_file(docs):
49
 
50
 
51
 
 
52
  def get_csv_file(docs):
53
  text_list = []
54
  for doc in docs:
 
32
  text_list = []
33
 
34
  # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜
35
+ def process_txt_file(file_content):
36
+ text = file_content.decode("utf-8")
37
+ text_list.append(text)
 
 
38
 
39
  # ์ฃผ์–ด์ง„ ํŒŒ์ผ ๋ชฉ๋ก์„ ๋ฐ˜๋ณตํ•˜๋ฉด์„œ ๊ฐ ํŒŒ์ผ์„ ์ฒ˜๋ฆฌ
40
+ for file_content in docs:
41
+ pdf_bytes = BytesIO(file_content)
42
+ process_txt_file(pdf_bytes.read()) # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜ ํ˜ธ์ถœ
43
 
44
  # ๋‹ค๋ฅธ ํŒŒ์ผ ์œ ํ˜•(PDF, CSV, JSON ๋“ฑ)์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ
45
  # ํ•„์š”ํ•˜๋‹ค๋ฉด ์—ฌ๊ธฐ์— ์ถ”๊ฐ€์ ์ธ ํŒŒ์ผ ์ฒ˜๋ฆฌ ๋กœ์ง์„ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
 
48
 
49
 
50
 
51
+
52
  def get_csv_file(docs):
53
  text_list = []
54
  for doc in docs: