[email protected]
commited on
Commit
Β·
b4b9a43
1
Parent(s):
5d88956
edit codes
Browse files
app.py
CHANGED
@@ -30,24 +30,10 @@ def get_pdf_text(pdf_docs):
|
|
30 |
# κ³Όμ
|
31 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
32 |
|
33 |
-
# def get_text_file(docs):
|
34 |
-
# temp_dir2 = tempfile.TemporaryDirectory() # μμ λλ ν 리λ₯Ό μμ±ν©λλ€.
|
35 |
-
# temp_filepath2 = os.path.join(temp_dir2.name, docs.name) # μμ νμΌ κ²½λ‘λ₯Ό μμ±ν©λλ€.
|
36 |
-
# with open(temp_filepath2, "wb") as f: # μμ νμΌμ λ°μ΄λ리 μ°κΈ° λͺ¨λλ‘ μ½λλ€.
|
37 |
-
# f.write(docs.getvalue()) # TXT λ¬Έμμ λ΄μ©μ μμ νμΌμ μλλ€.
|
38 |
-
# text_loader = TextLoader(
|
39 |
-
# file_path=temp_filepath2,
|
40 |
-
# txt_schema='',
|
41 |
-
# text_content=False
|
42 |
-
# ) # Use your specific text loader here.
|
43 |
-
# text_data = text_loader.load() # Extract text using the loader.
|
44 |
-
# return text_data # μΆμΆν ν
μ€νΈλ₯Ό λ°νν©λλ€.
|
45 |
def get_text_file(docs):
|
46 |
temp_dir2 = tempfile.TemporaryDirectory() # μμ λλ ν 리λ₯Ό μμ±ν©λλ€.
|
47 |
temp_filepath2 = os.path.join(temp_dir2.name, docs.name) # μμ νμΌ κ²½λ‘λ₯Ό μμ±ν©λλ€.
|
48 |
-
txt_loader = TextLoader(
|
49 |
-
file_path=temp_filepath2
|
50 |
-
)
|
51 |
txt_data = txt_loader.load()
|
52 |
return txt_data
|
53 |
|
@@ -56,18 +42,15 @@ def get_csv_file(docs):
|
|
56 |
temp_filepath3 = os.path.join(temp_dir3.name, docs.name)
|
57 |
with open(temp_filepath3, "wb") as f:
|
58 |
f.write(docs.getvalue())
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
# text_content=False
|
69 |
-
# )
|
70 |
-
# csv_data = csv_loader.load()
|
71 |
return csv_data
|
72 |
|
73 |
def get_json_file(docs):
|
|
|
30 |
# κ³Όμ
|
31 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
def get_text_file(docs):
|
34 |
temp_dir2 = tempfile.TemporaryDirectory() # μμ λλ ν 리λ₯Ό μμ±ν©λλ€.
|
35 |
temp_filepath2 = os.path.join(temp_dir2.name, docs.name) # μμ νμΌ κ²½λ‘λ₯Ό μμ±ν©λλ€.
|
36 |
+
txt_loader = TextLoader(temp_filepath2)
|
|
|
|
|
37 |
txt_data = txt_loader.load()
|
38 |
return txt_data
|
39 |
|
|
|
42 |
temp_filepath3 = os.path.join(temp_dir3.name, docs.name)
|
43 |
with open(temp_filepath3, "wb") as f:
|
44 |
f.write(docs.getvalue())
|
45 |
+
csv_loader = CSVLoader(
|
46 |
+
file_path=temp_filepath3,
|
47 |
+
csv_args={
|
48 |
+
"delimiter": ",",
|
49 |
+
"quotechar": '"',
|
50 |
+
"fieldnames": ["name", "school", "address", "phone"],
|
51 |
+
},
|
52 |
+
)
|
53 |
+
csv_data = csv_loader.load()
|
|
|
|
|
|
|
54 |
return csv_data
|
55 |
|
56 |
def get_json_file(docs):
|