se0kcess commited on
Commit
93090c0
โ€ข
1 Parent(s): 8ccd0bd

"update get_text_file"

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -24,12 +24,16 @@ def get_pdf_text(pdf_docs):
24
 
25
  # ๊ณผ์ œ
26
  # ์•„๋ž˜ ํ…์ŠคํŠธ ์ถ”์ถœ ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑ
 
 
 
27
  def get_text_file(txt_docs):
28
- with open(txt_docs, 'r', encoding='utf-8') as file:
29
- text_content = file.read()
30
- txt_loader = TextLoader(text_content)
31
- txt_doc = txt_loader.load()
32
- return txt_doc
 
33
 
34
  # CSV ํŒŒ์ผ๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜
35
  def get_csv_file(docs):
 
24
 
25
  # ๊ณผ์ œ
26
  # ์•„๋ž˜ ํ…์ŠคํŠธ ์ถ”์ถœ ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑ
27
+ import os
28
+ import tempfile
29
+
30
  def get_text_file(txt_docs):
31
+ temp_dir = tempfile.TemporaryDirectory()
32
+ temp_filepath = os.path.join(temp_dir.name, txt_docs.name)
33
+ with open(temp_filepath, "w", encoding="utf-8") as f:
34
+ f.write(txt_docs.getvalue())
35
+ txt_loader = TextLoader(temp_filepath)
36
+ return txt_loader
37
 
38
  # CSV ํŒŒ์ผ๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜
39
  def get_csv_file(docs):