DDingcheol commited on
Commit
e7ba74a
Β·
1 Parent(s): 4e51127

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
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
- filename = file.name
32
- file_extension = filename.split(".")[-1] # 파일 μ΄λ¦„μ—μ„œ ν™•μž₯자 μΆ”μΆœ
33
-
34
- if file_extension.lower() == 'txt':
35
- # 파일이 .txt인 경우
36
- text = file.getvalue().decode("utf-8") # 파일 λ‚΄μš©μ„ utf-8 ν˜•μ‹μœΌλ‘œ λ””μ½”λ”©ν•˜μ—¬ ν…μŠ€νŠΈλ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
37
- text_list.append(text)
38
- else:
39
- print(f"Unsupported file type: {file_extension}. Skipping processing.")
 
 
 
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