ombhojane's picture
Update app.py
65dac95 verified
raw
history blame
No virus
635 Bytes
import streamlit as st
import pandas as pd
import json
# Title of the app
st.title('Gen AI Jam JSON Visualizer')
# File uploader widget
uploaded_file = st.file_uploader("Choose a JSON file", type=['json'])
if uploaded_file is not None:
# Reading the file
file_data = json.load(uploaded_file)
# If the JSON is deeply nested, you may need to normalize it to create a flat table
if isinstance(file_data, list): # Assuming the JSON is an array of records
df = pd.json_normalize(file_data)
else:
df = pd.json_normalize(file_data, max_level=1)
# Display the dataframe as a table
st.write(df)