Spaces:
Runtime error
Runtime error
JinHyeong99
commited on
Commit
·
58c8c1d
1
Parent(s):
f0ea068
app.py
CHANGED
@@ -50,8 +50,18 @@ def get_csv_file(csv_docs):
|
|
50 |
def get_json_file(json_docs):
|
51 |
temp_dir = tempfile.TemporaryDirectory()
|
52 |
temp_filepath = os.path.join(temp_dir.name, json_docs.name)
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
json_loader = JSONLoader(
|
56 |
file_path=temp_filepath,
|
57 |
jq_schema='.')
|
|
|
50 |
def get_json_file(json_docs):
|
51 |
temp_dir = tempfile.TemporaryDirectory()
|
52 |
temp_filepath = os.path.join(temp_dir.name, json_docs.name)
|
53 |
+
data = json_docs.getvalue()
|
54 |
+
|
55 |
+
if isinstance(data, bytes):
|
56 |
+
mode = "wb"
|
57 |
+
elif isinstance(data, str):
|
58 |
+
mode = "w"
|
59 |
+
else:
|
60 |
+
raise ValueError("Unsupported data type")
|
61 |
+
|
62 |
+
with open(temp_filepath, mode) as f:
|
63 |
+
f.write(data)
|
64 |
+
|
65 |
json_loader = JSONLoader(
|
66 |
file_path=temp_filepath,
|
67 |
jq_schema='.')
|