Update app.py
Browse files
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 |
-
|
| 61 |
-
return
|
| 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 |
|