Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import json
|
4 |
+
|
5 |
+
# Title of the app
|
6 |
+
st.title('Gen AI Jam JSON Visualizer')
|
7 |
+
|
8 |
+
# File uploader widget
|
9 |
+
uploaded_file = st.file_uploader("Choose a JSON file", type=['json'])
|
10 |
+
if uploaded_file is not None:
|
11 |
+
# Reading the file
|
12 |
+
file_data = json.load(uploaded_file)
|
13 |
+
|
14 |
+
# If the JSON is deeply nested, you may need to normalize it to create a flat table
|
15 |
+
if isinstance(file_data, list): # Assuming the JSON is an array of records
|
16 |
+
df = pd.json_normalize(file_data)
|
17 |
+
else:
|
18 |
+
df = pd.json_normalize(file_data, max_level=1)
|
19 |
+
|
20 |
+
# Display the dataframe as a table
|
21 |
+
st.write(df)
|