Spaces:
Build error
Build error
Commit ยท
facb6cf
1
Parent(s): e0f22a9
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,22 +28,16 @@ def get_pdf_text(pdf_docs):
|
|
| 28 |
def get_text_file(docs):
|
| 29 |
text_list = []
|
| 30 |
for file in docs:
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
text_list.append(text)
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
#
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
else:
|
| 42 |
-
# ํ์ผ์ด .txt๊ฐ ์๋ ๊ฒฝ์ฐ ์ฒ๋ฆฌ
|
| 43 |
-
return None
|
| 44 |
-
except Exception as e:
|
| 45 |
-
print(f"An error occurred while extracting text: {e}")
|
| 46 |
-
return None
|
| 47 |
|
| 48 |
|
| 49 |
def get_csv_file(docs):
|
|
|
|
| 28 |
def get_text_file(docs):
|
| 29 |
text_list = []
|
| 30 |
for file in docs:
|
| 31 |
+
try:
|
| 32 |
+
if file.type == 'text/plain':
|
| 33 |
+
# ํ์ผ์ด .txt์ธ ๊ฒฝ์ฐ
|
| 34 |
+
text = file.read().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 |
+
|
| 40 |
+
return text_lis
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
def get_csv_file(docs):
|