Commit
ยท
a04e0a2
1
Parent(s):
64515bb
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,16 +32,15 @@ def get_text_file(docs):
|
|
| 32 |
text_list = []
|
| 33 |
|
| 34 |
# .txt ํ์ผ ์ฒ๋ฆฌ ํจ์
|
| 35 |
-
def process_txt_file(
|
| 36 |
-
|
| 37 |
-
file_extension = filename.split('.')[-1] # ํ์ผ ์ด๋ฆ์์ ํ์ฅ์ ์ถ์ถ
|
| 38 |
if file_extension == 'txt': # ์ถ์ถํ ํ์ฅ์๊ฐ 'txt'์ธ์ง ํ์ธ
|
| 39 |
-
text =
|
| 40 |
text_list.append(text)
|
| 41 |
|
| 42 |
# ์ฃผ์ด์ง ํ์ผ ๋ชฉ๋ก์ ๋ฐ๋ณตํ๋ฉด์ ๊ฐ ํ์ผ์ ์ฒ๋ฆฌ
|
| 43 |
-
for doc in docs:
|
| 44 |
-
process_txt_file(doc) # .txt ํ์ผ ์ฒ๋ฆฌ ํจ์ ํธ์ถ
|
| 45 |
|
| 46 |
# ๋ค๋ฅธ ํ์ผ ์ ํ(PDF, CSV, JSON ๋ฑ)์ ๋ํ ์ฒ๋ฆฌ
|
| 47 |
# ํ์ํ๋ค๋ฉด ์ฌ๊ธฐ์ ์ถ๊ฐ์ ์ธ ํ์ผ ์ฒ๋ฆฌ ๋ก์ง์ ๊ตฌํํฉ๋๋ค.
|
|
@@ -49,6 +48,7 @@ def get_text_file(docs):
|
|
| 49 |
return text_list
|
| 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(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 |
# ํ์ํ๋ค๋ฉด ์ฌ๊ธฐ์ ์ถ๊ฐ์ ์ธ ํ์ผ ์ฒ๋ฆฌ ๋ก์ง์ ๊ตฌํํฉ๋๋ค.
|
|
|
|
| 48 |
return text_list
|
| 49 |
|
| 50 |
|
| 51 |
+
|
| 52 |
def get_csv_file(docs):
|
| 53 |
text_list = []
|
| 54 |
for doc in docs:
|