Spaces:
Sleeping
Sleeping
commit_5
Browse files
app.py
CHANGED
@@ -35,7 +35,7 @@ def get_pdf_text(pdf_docs):
|
|
35 |
def get_text_file(docs):
|
36 |
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
37 |
temp_filepath = os.path.join(temp_dir.name, docs.name) # ์์ ํ์ผ ๊ฒฝ๋ก๋ฅผ ์์ฑํฉ๋๋ค.
|
38 |
-
with open(temp_filepath, "
|
39 |
f.write(docs.getvalue()) # text ๋ฌธ์์ ๋ด์ฉ์ ์์ ํ์ผ์ ์๋๋ค.
|
40 |
text_loader = TextLoader(temp_filepath) # TextLoader๋ฅผ ์ฌ์ฉํด text๋ฅผ ๋ก๋ํฉ๋๋ค.
|
41 |
text_doc = text_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
@@ -44,7 +44,7 @@ def get_text_file(docs):
|
|
44 |
def get_csv_file(docs):
|
45 |
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
46 |
temp_filepath = os.path.join(temp_dir.name, docs.name) # ์์ ํ์ผ ๊ฒฝ๋ก๋ฅผ ์์ฑํฉ๋๋ค.
|
47 |
-
with open(temp_filepath, "
|
48 |
f.write(docs.getvalue()) # csv ๋ฌธ์์ ๋ด์ฉ์ ์์ ํ์ผ์ ์๋๋ค.
|
49 |
csv_loader = CSVLoader(temp_filepath) # CSVLoader๋ฅผ ์ฌ์ฉํด csv์ ๋ก๋ํฉ๋๋ค.
|
50 |
csv_doc = csv_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
@@ -53,7 +53,7 @@ def get_csv_file(docs):
|
|
53 |
def get_json_file(docs):
|
54 |
temp_dir = tempfile.TemporaryDirectory()
|
55 |
temp_filepath = os.path.join(temp_dir.name, docs.name)
|
56 |
-
with open(temp_filepath, "
|
57 |
f.write(docs.getvalue())
|
58 |
json_loader = JSONLoader(temp_filepath)
|
59 |
json_data = json_loader.load()
|
|
|
35 |
def get_text_file(docs):
|
36 |
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
37 |
temp_filepath = os.path.join(temp_dir.name, docs.name) # ์์ ํ์ผ ๊ฒฝ๋ก๋ฅผ ์์ฑํฉ๋๋ค.
|
38 |
+
with open(temp_filepath, "wb") as f: # ์์ ํ์ผ์ ๋ฐ์ด๋๋ฆฌ ์ฐ๊ธฐ ๋ชจ๋๋ก ์ฝ๋๋ค.
|
39 |
f.write(docs.getvalue()) # text ๋ฌธ์์ ๋ด์ฉ์ ์์ ํ์ผ์ ์๋๋ค.
|
40 |
text_loader = TextLoader(temp_filepath) # TextLoader๋ฅผ ์ฌ์ฉํด text๋ฅผ ๋ก๋ํฉ๋๋ค.
|
41 |
text_doc = text_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
|
|
44 |
def get_csv_file(docs):
|
45 |
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
46 |
temp_filepath = os.path.join(temp_dir.name, docs.name) # ์์ ํ์ผ ๊ฒฝ๋ก๋ฅผ ์์ฑํฉ๋๋ค.
|
47 |
+
with open(temp_filepath, "wb") as f: # ์์ ํ์ผ์ ํ
์คํธ ์ฐ๊ธฐ ๋ชจ๋๋ก ์ฝ๋๋ค.
|
48 |
f.write(docs.getvalue()) # csv ๋ฌธ์์ ๋ด์ฉ์ ์์ ํ์ผ์ ์๋๋ค.
|
49 |
csv_loader = CSVLoader(temp_filepath) # CSVLoader๋ฅผ ์ฌ์ฉํด csv์ ๋ก๋ํฉ๋๋ค.
|
50 |
csv_doc = csv_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
|
|
53 |
def get_json_file(docs):
|
54 |
temp_dir = tempfile.TemporaryDirectory()
|
55 |
temp_filepath = os.path.join(temp_dir.name, docs.name)
|
56 |
+
with open(temp_filepath, "wb") as f:
|
57 |
f.write(docs.getvalue())
|
58 |
json_loader = JSONLoader(temp_filepath)
|
59 |
json_data = json_loader.load()
|