Commit
ยท
0d627c2
1
Parent(s):
a531e8e
Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,7 @@ def get_pdf_text(pdf_docs):
|
|
25 |
|
26 |
# ๊ณผ์
|
27 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
|
|
28 |
def get_text_file(docs):
|
29 |
text_list = []
|
30 |
try:
|
@@ -44,7 +45,24 @@ def get_text_file(docs):
|
|
44 |
print(f"An error occurred while processing files: {ex}")
|
45 |
|
46 |
return text_list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
|
|
48 |
|
49 |
def get_csv_file(docs):
|
50 |
pass
|
|
|
25 |
|
26 |
# ๊ณผ์
|
27 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
28 |
+
'''
|
29 |
def get_text_file(docs):
|
30 |
text_list = []
|
31 |
try:
|
|
|
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 |
+
for file in docs:
|
52 |
+
if file.type == 'text/plain':
|
53 |
+
try:
|
54 |
+
# ํ์ผ์ด .txt์ธ ๊ฒฝ์ฐ
|
55 |
+
text = file.getvalue().decode("utf-8") # ํ์ผ ๋ด์ฉ์ utf-8 ํ์์ผ๋ก ๋์ฝ๋ฉํ์ฌ ํ
์คํธ๋ก ๋ณํํฉ๋๋ค.
|
56 |
+
text_list.append(text)
|
57 |
+
except UnicodeDecodeError as decode_error:
|
58 |
+
print(f"UnicodeDecodeError occurred while decoding text: {decode_error}")
|
59 |
+
# ํ์ผ์ ๋ค๋ฅธ ๋ฐฉ์์ผ๋ก ๋์ฝ๋ฉํ๊ฑฐ๋ ๊ฑด๋๋ฐ๋๋ก ์ฒ๋ฆฌํ ์ ์์ต๋๋ค.
|
60 |
+
continue
|
61 |
+
except Exception as e:
|
62 |
+
print(f"An error occurred while extracting text: {e}")
|
63 |
+
continue # ๋ค๋ฅธ ์์ธ๊ฐ ๋ฐ์ํ๋ฉด ๊ฑด๋๋๋๋ค.
|
64 |
|
65 |
+
return text_list
|
66 |
|
67 |
def get_csv_file(docs):
|
68 |
pass
|