Update app.py
Browse files
app.py
CHANGED
|
@@ -52,25 +52,27 @@ def get_csv_file(csv_docs):
|
|
| 52 |
|
| 53 |
|
| 54 |
# json ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
|
| 75 |
|
| 76 |
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
# json ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
| 55 |
+
|
| 56 |
+
def extract_text_from_json_file(file_path):
|
| 57 |
+
try:
|
| 58 |
+
with open(file_path, 'r') as file:
|
| 59 |
+
data = json.load(file)
|
| 60 |
+
|
| 61 |
+
# 'users' ํค์ ๊ฐ์ ์ถ์ถ
|
| 62 |
+
users_data = data.get('users', [])
|
| 63 |
+
|
| 64 |
+
# 'users' ๋ฐฐ์ด์ ๊ฐ ์์์์ 'firstName' ํค์ ๊ฐ์ ์ถ์ถํ์ฌ ๋ฆฌ์คํธ์ ์ ์ฅ
|
| 65 |
+
first_names = [user.get('firstName', '') for user in users_data]
|
| 66 |
+
|
| 67 |
+
# ์ถ์ถํ ๊ฐ ๋ฆฌ์คํธ๋ฅผ ๋ฌธ์์ด๋ก ๋ณํํ์ฌ ๋ฐํ
|
| 68 |
+
text = ', '.join(first_names)
|
| 69 |
+
return text
|
| 70 |
+
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
return f"File not found: {file_path}"
|
| 73 |
+
except json.JSONDecodeError as e:
|
| 74 |
+
return f"Invalid JSON format: {e}"
|
| 75 |
+
|
| 76 |
|
| 77 |
|
| 78 |
|