Update app.py
#5
by
namkwonwoo
- opened
app.py
CHANGED
@@ -24,14 +24,33 @@ def get_pdf_text(pdf_docs):
|
|
24 |
|
25 |
# κ³Όμ
|
26 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
27 |
-
def get_text_file(
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
|
37 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
|
|
24 |
|
25 |
# κ³Όμ
|
26 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
27 |
+
def get_text_file(text_docs):
|
28 |
+
temp_dir = tempfile.TemporaryDirectory()
|
29 |
+
temp_filepath = os.path.join(temp_dir.name, text_docs.name)
|
30 |
+
with open(temp_filepath, "wb") as f:
|
31 |
+
f.write(text_docs.getvalue())
|
32 |
+
text_loader = TextLoader(temp_filepath)
|
33 |
+
text_doc = text_loader.load()
|
34 |
+
return text_doc
|
35 |
+
|
36 |
+
|
37 |
+
def get_csv_file(csv_docs):
|
38 |
+
temp_dir = tempfile.TemporaryDirectory()
|
39 |
+
temp_filepath = os.path.join(temp_dir.name, csv_docs.name)
|
40 |
+
with open(temp_filepath, "wb") as f:
|
41 |
+
f.write(csv_docs.getvalue())
|
42 |
+
csv_loader = CSVLoader(temp_filepath)
|
43 |
+
csv_doc = csv_loader.load()
|
44 |
+
return csv_doc
|
45 |
+
|
46 |
+
def get_json_file(json_docs):
|
47 |
+
temp_dir = tempfile.TemporaryDirectory()
|
48 |
+
temp_filepath = os.path.join(temp_dir.name, json_docs.name)
|
49 |
+
with open(temp_filepath, "wb") as f:
|
50 |
+
f.write(json_docs.getvalue())
|
51 |
+
json_loader = JSONLoader(temp_filepath)
|
52 |
+
json_doc = json_loader.load()
|
53 |
+
return json_doc
|
54 |
|
55 |
|
56 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|