Daoneeee commited on
Commit
fcafbc1
·
1 Parent(s): 62f948e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -38,9 +38,14 @@ def get_text_file(text_docs):
38
  text_doc = text_loader.load() # 텍스트를 추출합니다.
39
  return text_doc # 추출한 텍스트를 반환합니다.
40
 
41
- def get_csv_file(docs):
42
- csv_loader = CSVLoader(docs) # CSV 파일을 처리할 CSVLoader 사용
43
- return csv_loader.load()
 
 
 
 
 
44
 
45
  def get_json_file(docs):
46
  json_loader = JSONLoader(docs) # JSON 파일을 처리할 JSONLoader 사용
 
38
  text_doc = text_loader.load() # 텍스트를 추출합니다.
39
  return text_doc # 추출한 텍스트를 반환합니다.
40
 
41
+ def get_csv_file(csv_docs):
42
+ temp_dir = tempfile.TemporaryDirectory() # 임시 디렉토리를 생성합니다.
43
+ temp_filepath = os.path.join(temp_dir.name, csv_docs.name) # 임시 파일 경로를 생성합니다.
44
+ with open(temp_filepath, "wb") as f: # 임시 파일을 바이너리 쓰기 모드로 엽니다.
45
+ f.write(csv_docs.getvalue()) # PDF 문서의 내용을 임시 파일에 씁니다.
46
+ csv_loader = CSVLoader(temp_filepath) # PyPDFLoader를 사용해 PDF를 로드합니다.
47
+ csv_doc = csv_loader.load() # 텍스트를 추출합니다.
48
+ return csv_doc # 추출한 텍스트를 반환합니다.
49
 
50
  def get_json_file(docs):
51
  json_loader = JSONLoader(docs) # JSON 파일을 처리할 JSONLoader 사용