Commit ยท
3fecf20
1
Parent(s): 6974986
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,38 +25,19 @@ def get_pdf_text(pdf_docs):
|
|
| 25 |
|
| 26 |
# ๊ณผ์
|
| 27 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 28 |
-
'''
|
| 29 |
def get_text_file(docs):
|
| 30 |
text_list = []
|
| 31 |
try:
|
| 32 |
for file in docs:
|
| 33 |
try:
|
| 34 |
-
if file
|
| 35 |
-
# ํ์ผ
|
| 36 |
-
text = file.getvalue().decode("utf-8") # ํ์ผ ๋ด์ฉ์ utf-8 ํ์์ผ๋ก ๋์ฝ๋ฉํ์ฌ ํ
์คํธ๋ก ๋ณํํฉ๋๋ค.
|
| 37 |
text_list.append(text)
|
| 38 |
-
except IndexError as ie:
|
| 39 |
-
print(f"IndexError occurred while processing a text file: {ie}")
|
| 40 |
-
continue # IndexError๊ฐ ๋ฐ์ํ์ ๊ฒฝ์ฐ ์ฒ๋ฆฌ๋ฅผ ๊ฑด๋๋๋๋ค.
|
| 41 |
except Exception as e:
|
| 42 |
print(f"An error occurred while extracting text: {e}")
|
| 43 |
-
continue
|
| 44 |
except Exception as ex:
|
| 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 |
-
try:
|
| 52 |
-
text = docs.getvalue().decode("utf-8") # ํ์ผ ๋ด์ฉ์ utf-8 ํ์์ผ๋ก ๋์ฝ๋ฉํ์ฌ ํ
์คํธ๋ก ๋ณํํฉ๋๋ค.
|
| 53 |
-
text_list.append(text)
|
| 54 |
-
except UnicodeDecodeError as decode_error:
|
| 55 |
-
print(f"UnicodeDecodeError occurred while decoding text: {decode_error}")
|
| 56 |
-
# ํ์ผ์ ๋ค๋ฅธ ๋ฐฉ์์ผ๋ก ๋์ฝ๋ฉํ๊ฑฐ๋ ๊ฑด๋๋ฐ๋๋ก ์ฒ๋ฆฌํ ์ ์์ต๋๋ค.
|
| 57 |
-
except Exception as e:
|
| 58 |
-
print(f"An error occurred while extracting text: {e}")
|
| 59 |
-
|
| 60 |
return text_list
|
| 61 |
|
| 62 |
def get_csv_file(docs):
|
|
|
|
| 25 |
|
| 26 |
# ๊ณผ์
|
| 27 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
|
|
|
| 28 |
def get_text_file(docs):
|
| 29 |
text_list = []
|
| 30 |
try:
|
| 31 |
for file in docs:
|
| 32 |
try:
|
| 33 |
+
if isinstance(file, bytes):
|
| 34 |
+
text = file.decode("utf-8") # ํ์ผ ๋ด์ฉ์ utf-8 ํ์์ผ๋ก ๋์ฝ๋ฉํ์ฌ ํ
์คํธ๋ก ๋ณํํฉ๋๋ค.
|
|
|
|
| 35 |
text_list.append(text)
|
|
|
|
|
|
|
|
|
|
| 36 |
except Exception as e:
|
| 37 |
print(f"An error occurred while extracting text: {e}")
|
| 38 |
+
continue
|
| 39 |
except Exception as ex:
|
| 40 |
print(f"An error occurred while processing files: {ex}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
return text_list
|
| 42 |
|
| 43 |
def get_csv_file(docs):
|