Update app.py
Browse files
app.py
CHANGED
@@ -25,11 +25,28 @@ def get_pdf_text(pdf_docs):
|
|
25 |
# κ³Όμ
|
26 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
27 |
|
28 |
-
def get_text_file(text_docs):
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
return [text_content] # μΆμΆν ν
μ€νΈλ₯Ό 리μ€νΈμ λ΄μ λ°νν©λλ€.
|
31 |
|
32 |
|
|
|
33 |
def get_csv_file(csv_docs):
|
34 |
temp_dir = tempfile.TemporaryDirectory() # μμ λλ ν 리λ₯Ό μμ±ν©λλ€.
|
35 |
temp_filepath = os.path.join(temp_dir.name, "temp_file.csv") # μμ νμΌ κ²½λ‘λ₯Ό μμ±ν©λλ€.
|
|
|
25 |
# κ³Όμ
|
26 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
27 |
|
28 |
+
def get_text_file(text_docs):
|
29 |
+
# μμ λλ ν 리λ₯Ό μμ±ν©λλ€.
|
30 |
+
temp_dir = tempfile.TemporaryDirectory()
|
31 |
+
|
32 |
+
# μμ νμΌ κ²½λ‘λ₯Ό μμ±ν©λλ€.
|
33 |
+
temp_filepath = os.path.join(temp_dir.name, "temp_file.txt")
|
34 |
+
|
35 |
+
# ν
μ€νΈ λ¬Έμμ λ΄μ©μ μμ νμΌμ μλλ€.
|
36 |
+
with open(temp_filepath, "w", encoding="utf-8") as f:
|
37 |
+
f.write(text_docs.getvalue())
|
38 |
+
|
39 |
+
# μμ νμΌμμ ν
μ€νΈλ₯Ό μ½μ΄μ΅λλ€.
|
40 |
+
with open(temp_filepath, "r", encoding="utf-8") as f:
|
41 |
+
text_content = f.read()
|
42 |
+
|
43 |
+
# μμ λλ ν 리λ₯Ό μλμΌλ‘ μ 리ν©λλ€.
|
44 |
+
temp_dir.cleanup()
|
45 |
+
|
46 |
return [text_content] # μΆμΆν ν
μ€νΈλ₯Ό 리μ€νΈμ λ΄μ λ°νν©λλ€.
|
47 |
|
48 |
|
49 |
+
|
50 |
def get_csv_file(csv_docs):
|
51 |
temp_dir = tempfile.TemporaryDirectory() # μμ λλ ν 리λ₯Ό μμ±ν©λλ€.
|
52 |
temp_filepath = os.path.join(temp_dir.name, "temp_file.csv") # μμ νμΌ κ²½λ‘λ₯Ό μμ±ν©λλ€.
|