han-byeol commited on
Commit
3ed3971
ยท
1 Parent(s): 9138e47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -51,15 +51,25 @@ def get_csv_file(csv_docs):
51
 
52
 
53
  # json ๋ฌธ์„œ๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜
 
 
 
 
 
 
 
 
 
 
 
54
  def get_json_file(json_docs):
55
  temp_dir = tempfile.TemporaryDirectory()
56
  temp_filepath = os.path.join(temp_dir.name, json_docs.name)
57
  with open(temp_filepath, "wb") as f:
58
  f.write(json_docs.getvalue())
59
  json_loader = JSONLoader(temp_filepath, jq_schema={})
60
- json_doc = json_loader.load()
61
- return json_doc
62
-
63
 
64
 
65
 
 
51
 
52
 
53
  # json ๋ฌธ์„œ๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜
54
+ class JSONLoader:
55
+ def __init__(self, file_path, jq_schema):
56
+ self.file_path = file_path
57
+ self.jq_schema = jq_schema
58
+
59
+ def load(self):
60
+ with open(self.file_path, 'r') as json_file:
61
+ data = json.load(json_file)
62
+ users_text = [user.get('text', '') for user in data.get('users', [])]
63
+ return users_text
64
+
65
  def get_json_file(json_docs):
66
  temp_dir = tempfile.TemporaryDirectory()
67
  temp_filepath = os.path.join(temp_dir.name, json_docs.name)
68
  with open(temp_filepath, "wb") as f:
69
  f.write(json_docs.getvalue())
70
  json_loader = JSONLoader(temp_filepath, jq_schema={})
71
+ users_text = json_loader.load()
72
+ return users_text
 
73
 
74
 
75