Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,7 @@ 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, "w", encoding="utf-8") as textfile:
|
31 |
-
textfile.write(text_data.getvalue())
|
32 |
text_loader = TextLoader(temp_filepath)
|
33 |
text = text_loader.load()
|
34 |
return text
|
@@ -37,7 +37,7 @@ def get_csv_text(csv_file):
|
|
37 |
temp_dir = tempfile.TemporaryDirectory()
|
38 |
temp_filepath = os.path.join(temp_dir.name, csv_file.name)
|
39 |
with open(temp_filepath, "w", encoding="utf-8") as csvfile:
|
40 |
-
csvfile.write(csv_file.getvalue())
|
41 |
csv_loader = CSVLoader(temp_filepath, text_column='text_column_name')
|
42 |
csv_data = csv_loader.load()
|
43 |
text_from_csv = '\n'.join(csv_data['text_column_name']) if 'text_column_name' in csv_data else ''
|
@@ -47,7 +47,7 @@ def get_json_file(json_datas):
|
|
47 |
temp_dir = tempfile.TemporaryDirectory() # 임시 디렉토리를 생성합니다.
|
48 |
temp_filepath = os.path.join(temp_dir.name, json_datas.name) # 임시 JSON 파일 경로를 생성합니다.
|
49 |
with open(temp_filepath, "w", encoding="utf-8") as jsonfile: # JSON 파일을 쓰기 모드로 엽니다.
|
50 |
-
jsonfile.write(json_datas.getvalue()) # JSON 데이터를 파일에 씁니다.
|
51 |
json_loader = JSONLoader(
|
52 |
temp_filepath,
|
53 |
jq_schema='messages[].content',
|
|
|
28 |
temp_dir = tempfile.TemporaryDirectory()
|
29 |
temp_filepath = os.path.join(temp_dir.name, text_data.name)
|
30 |
with open(temp_filepath, "w", encoding="utf-8") as textfile:
|
31 |
+
textfile.write(text_data.getvalue().decode('utf-8'))
|
32 |
text_loader = TextLoader(temp_filepath)
|
33 |
text = text_loader.load()
|
34 |
return text
|
|
|
37 |
temp_dir = tempfile.TemporaryDirectory()
|
38 |
temp_filepath = os.path.join(temp_dir.name, csv_file.name)
|
39 |
with open(temp_filepath, "w", encoding="utf-8") as csvfile:
|
40 |
+
csvfile.write(csv_file.getvalue().decode('utf-8'))
|
41 |
csv_loader = CSVLoader(temp_filepath, text_column='text_column_name')
|
42 |
csv_data = csv_loader.load()
|
43 |
text_from_csv = '\n'.join(csv_data['text_column_name']) if 'text_column_name' in csv_data else ''
|
|
|
47 |
temp_dir = tempfile.TemporaryDirectory() # 임시 디렉토리를 생성합니다.
|
48 |
temp_filepath = os.path.join(temp_dir.name, json_datas.name) # 임시 JSON 파일 경로를 생성합니다.
|
49 |
with open(temp_filepath, "w", encoding="utf-8") as jsonfile: # JSON 파일을 쓰기 모드로 엽니다.
|
50 |
+
jsonfile.write(json_datas.getvalue().decode('utf-8')) # JSON 데이터를 파일에 씁니다.
|
51 |
json_loader = JSONLoader(
|
52 |
temp_filepath,
|
53 |
jq_schema='messages[].content',
|