DDingcheol commited on
Commit
bd29c3c
Β·
1 Parent(s): 3fecf20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -27,17 +27,14 @@ def get_pdf_text(pdf_docs):
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):
 
27
  # μ•„λž˜ ν…μŠ€νŠΈ μΆ”μΆœ ν•¨μˆ˜λ₯Ό μž‘μ„±
28
  def get_text_file(docs):
29
  text_list = []
30
+ for file in docs:
31
+ if file.type == 'text/plain':
32
+ # 파일이 .txt인 경우
33
+ text = file.getvalue().decode("utf-8") # 파일 λ‚΄μš©μ„ utf-8 ν˜•μ‹μœΌλ‘œ λ””μ½”λ”©ν•˜μ—¬ ν…μŠ€νŠΈλ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
34
+ text_list.append(text)
35
+ else:
36
+ print(f"Unsupported file type: {file.type}. Skipping processing.")
37
+
 
 
 
38
  return text_list
39
 
40
  def get_csv_file(docs):