Update app.py
Browse files
app.py
CHANGED
|
@@ -27,16 +27,34 @@ def get_pdf_text(pdf_docs):
|
|
| 27 |
|
| 28 |
# ๊ณผ์
|
| 29 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 30 |
-
|
| 31 |
def get_text_file(docs):
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
|
|
|
| 35 |
def get_csv_file(docs):
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
|
|
|
|
|
|
| 38 |
def get_json_file(docs):
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
|
| 42 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
|
|
|
| 27 |
|
| 28 |
# ๊ณผ์
|
| 29 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 30 |
+
# txt ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
| 31 |
def get_text_file(docs):
|
| 32 |
+
text_data = ""
|
| 33 |
+
for doc in docs:
|
| 34 |
+
if doc.type == 'text/plain':
|
| 35 |
+
text_data += doc.getvalue().decode("utf-8")
|
| 36 |
+
# Plain text ํ์ผ์ด๋ฉด ํด๋น ํ
์คํธ๋ฅผ text_data์ ์ถ๊ฐํฉ๋๋ค.
|
| 37 |
+
return text_data
|
| 38 |
|
| 39 |
|
| 40 |
+
# csv ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
| 41 |
def get_csv_file(docs):
|
| 42 |
+
csv_data = ""
|
| 43 |
+
for doc in docs:
|
| 44 |
+
if doc.type == 'text/csv':
|
| 45 |
+
csv_data += doc.getvalue().decode("utf-8")
|
| 46 |
+
# CSV ํ์ผ์ด๋ฉด ํด๋น ๋ฐ์ดํฐ๋ฅผ csv_data์ ์ถ๊ฐํฉ๋๋ค.
|
| 47 |
+
return csv_data
|
| 48 |
|
| 49 |
+
|
| 50 |
+
# json ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
| 51 |
def get_json_file(docs):
|
| 52 |
+
json_data = ""
|
| 53 |
+
for doc in docs:
|
| 54 |
+
if doc.type == 'application/json':
|
| 55 |
+
json_data += doc.getvalue().decode("utf-8")
|
| 56 |
+
# JSON ํ์ผ์ด๋ฉด ํด๋น ๋ฐ์ดํฐ๋ฅผ json_data์ ์ถ๊ฐํฉ๋๋ค.
|
| 57 |
+
return json_data
|
| 58 |
|
| 59 |
|
| 60 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|