Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,12 +25,12 @@ def get_pdf_text(pdf_docs):
|
|
| 25 |
# 과제
|
| 26 |
# 아래 텍스트 추출 함수를 작성
|
| 27 |
def get_text_file(text_data):
|
| 28 |
-
temp_dir = tempfile.TemporaryDirectory()
|
| 29 |
-
temp_filepath = os.path.join(temp_dir.name, text_data.name)
|
| 30 |
-
with open(temp_filepath, "wb") as f:
|
| 31 |
-
f.write(text_data.getvalue())
|
| 32 |
|
| 33 |
-
|
| 34 |
text_loader = TextLoader(temp_filepath)
|
| 35 |
text = text_loader.load()
|
| 36 |
|
|
@@ -43,19 +43,18 @@ def get_csv_file(csv_file):
|
|
| 43 |
with open(temp_filepath, "wb") as f:
|
| 44 |
f.write(csv_file.getvalue())
|
| 45 |
|
| 46 |
-
csv_loader = CSVLoader(temp_filepath)
|
| 47 |
csv_data = csv_loader.load()
|
| 48 |
|
| 49 |
-
return csv_data
|
| 50 |
-
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
def get_json_file(json_datas):
|
| 55 |
-
temp_dir = tempfile.TemporaryDirectory()
|
| 56 |
-
temp_filepath = os.path.join(temp_dir.name, json_datas.name)
|
| 57 |
-
with open(temp_filepath, "w", encoding="utf-8") as jsonfile:
|
| 58 |
-
jsonfile.write(json_datas.getvalue().decode('utf-8'))
|
| 59 |
json_loader = JSONLoader(
|
| 60 |
temp_filepath,
|
| 61 |
jq_schema='.',
|
|
|
|
| 25 |
# 과제
|
| 26 |
# 아래 텍스트 추출 함수를 작성
|
| 27 |
def get_text_file(text_data):
|
| 28 |
+
temp_dir = tempfile.TemporaryDirectory()
|
| 29 |
+
temp_filepath = os.path.join(temp_dir.name, text_data.name)
|
| 30 |
+
with open(temp_filepath, "wb") as f:
|
| 31 |
+
f.write(text_data.getvalue())
|
| 32 |
|
| 33 |
+
|
| 34 |
text_loader = TextLoader(temp_filepath)
|
| 35 |
text = text_loader.load()
|
| 36 |
|
|
|
|
| 43 |
with open(temp_filepath, "wb") as f:
|
| 44 |
f.write(csv_file.getvalue())
|
| 45 |
|
| 46 |
+
csv_loader = CSVLoader(temp_filepath)
|
| 47 |
csv_data = csv_loader.load()
|
| 48 |
|
| 49 |
+
return csv_data
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
def get_json_file(json_datas):
|
| 54 |
+
temp_dir = tempfile.TemporaryDirectory()
|
| 55 |
+
temp_filepath = os.path.join(temp_dir.name, json_datas.name)
|
| 56 |
+
with open(temp_filepath, "w", encoding="utf-8") as jsonfile:
|
| 57 |
+
jsonfile.write(json_datas.getvalue().decode('utf-8'))
|
| 58 |
json_loader = JSONLoader(
|
| 59 |
temp_filepath,
|
| 60 |
jq_schema='.',
|