Spaces:
Build error
Build error
Commit Β·
e7ba74a
1
Parent(s): 4e51127
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,15 +28,18 @@ 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 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
return text_list
|
| 42 |
|
|
|
|
| 28 |
def get_text_file(docs):
|
| 29 |
text_list = []
|
| 30 |
for file in docs:
|
| 31 |
+
try:
|
| 32 |
+
filename = file.name
|
| 33 |
+
file_extension = filename.split(".")[-1].lower() # νμΌ μ΄λ¦μμ νμ₯μ μΆμΆνμ¬ μλ¬Έμλ‘ λ³ν
|
| 34 |
+
|
| 35 |
+
if file_extension == 'txt':
|
| 36 |
+
# νμΌμ΄ .txtμΈ κ²½μ°
|
| 37 |
+
text = file.getvalue().decode("utf-8") # νμΌ λ΄μ©μ utf-8 νμμΌλ‘ λμ½λ©νμ¬ ν
μ€νΈλ‘ λ³νν©λλ€.
|
| 38 |
+
text_list.append(text)
|
| 39 |
+
else:
|
| 40 |
+
print(f"Unsupported file type: {file_extension}. Skipping processing.")
|
| 41 |
+
except Exception as e:
|
| 42 |
+
print(f"An error occurred while processing the file: {e}")
|
| 43 |
|
| 44 |
return text_list
|
| 45 |
|