JinHyeong99 commited on
Commit
35b9fa3
Β·
1 Parent(s): 8075e7f
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -50,24 +50,17 @@ 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
- # read() λ©”μ„œλ“œλ₯Ό μ‚¬μš©ν•˜μ—¬ 데이터 읽기
54
- data = json_docs.read()
55
-
56
- # 데이터 νƒ€μž…μ— 따라 μ μ ˆν•œ λͺ¨λ“œ 선택
57
- if isinstance(data, bytes):
58
- mode = "wb"
59
- elif isinstance(data, str):
60
- mode = "w"
61
- else:
62
- raise ValueError("Unsupported data type")
63
-
64
- with open(temp_filepath, mode) as f:
65
  f.write(data)
66
 
67
  json_loader = JSONLoader(
68
- file_path=temp_filepath,
69
- jq_schema=None)
 
70
  json_doc = json_loader.load()
 
71
  return json_doc
72
 
73
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
 
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
+ data = open(json_docs, mode='r', encoding='utf-8')
55
+ with open(temp_filepath) as f:
 
 
 
 
 
 
 
 
 
56
  f.write(data)
57
 
58
  json_loader = JSONLoader(
59
+ file_path = temp_filepath,
60
+ jq_schema = '.'
61
+ )
62
  json_doc = json_loader.load()
63
+
64
  return json_doc
65
 
66
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.