DDingcheol commited on
Commit
facb6cf
ยท
1 Parent(s): e0f22a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -15
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
- if file.type == 'text/plain':
32
- # ํŒŒ์ผ์ด .txt์ธ ๊ฒฝ์šฐ
33
- text = extract_text_from_file(file)
34
- if text:
35
  text_list.append(text)
36
- try:
37
- if file.type == 'text/plain':
38
- # ํŒŒ์ผ์ด .txt์ธ ๊ฒฝ์šฐ
39
- text = file.read().decode("utf-8") # ํŒŒ์ผ ๋‚ด์šฉ์„ utf-8 ํ˜•์‹์œผ๋กœ ๋””์ฝ”๋”ฉํ•˜์—ฌ ํ…์ŠคํŠธ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
40
- return text
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):