Spaces:
Sleeping
Sleeping
Update pages/hari.py
Browse files- pages/hari.py +148 -33
pages/hari.py
CHANGED
|
@@ -1,42 +1,157 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
st.title("Types of Data")
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
if
|
| 14 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
if st.button("Excel"):
|
| 16 |
-
st.
|
| 17 |
-
|
| 18 |
-
elif data_type == "Semi-Structured
|
| 19 |
-
st.
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
elif data_type == "Unstructured Data":
|
| 34 |
-
st.subheader("Unstructured Data")
|
| 35 |
-
# Buttons for Image and Video
|
| 36 |
if st.button("Image"):
|
| 37 |
-
st.
|
| 38 |
if st.button("Video"):
|
| 39 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
|
| 4 |
+
# Define functions for individual pages
|
|
|
|
| 5 |
|
| 6 |
+
# Structured Data - Excel Page
|
| 7 |
+
def excel_details_page():
|
| 8 |
+
st.title("Structured Data - Excel Details")
|
| 9 |
+
st.markdown("""
|
| 10 |
+
**Excel** files store structured data in a tabular format with rows and columns.
|
| 11 |
|
| 12 |
+
- Commonly used for data analysis and reporting.
|
| 13 |
+
- Supports multiple sheets in a single file.
|
| 14 |
+
- Easily readable and writable using libraries like `pandas`.
|
| 15 |
+
""")
|
| 16 |
+
st.code('df = pd.read_excel("file.xlsx")', language="python")
|
| 17 |
|
| 18 |
+
if st.button("Back to Home"):
|
| 19 |
+
st.session_state['page'] = "home"
|
| 20 |
+
|
| 21 |
+
# Semi-Structured Data - CSV Page
|
| 22 |
+
def csv_details_page():
|
| 23 |
+
st.title("Semi-Structured Data - CSV Details")
|
| 24 |
+
st.markdown("""
|
| 25 |
+
**CSV** (Comma-Separated Values) files are plain text files that store tabular data.
|
| 26 |
+
|
| 27 |
+
- Easy to read and process using libraries like `pandas`.
|
| 28 |
+
- Each line represents a row, and commas separate the columns.
|
| 29 |
+
""")
|
| 30 |
+
st.code('df = pd.read_csv("file.csv")', language="python")
|
| 31 |
+
|
| 32 |
+
if st.button("Back to Home"):
|
| 33 |
+
st.session_state['page'] = "home"
|
| 34 |
+
|
| 35 |
+
# Semi-Structured Data - JSON Page
|
| 36 |
+
def json_details_page():
|
| 37 |
+
st.title("Semi-Structured Data - JSON Details")
|
| 38 |
+
st.markdown("""
|
| 39 |
+
**JSON** (JavaScript Object Notation) is a lightweight data-interchange format.
|
| 40 |
+
|
| 41 |
+
- Represents data as key-value pairs.
|
| 42 |
+
- Widely used for APIs and configuration files.
|
| 43 |
+
- Readable and writable using Python's `json` module.
|
| 44 |
+
""")
|
| 45 |
+
st.code('import json\ndata = json.load(open("file.json"))', language="python")
|
| 46 |
+
|
| 47 |
+
if st.button("Back to Home"):
|
| 48 |
+
st.session_state['page'] = "home"
|
| 49 |
+
|
| 50 |
+
# Semi-Structured Data - XML Page
|
| 51 |
+
def xml_details_page():
|
| 52 |
+
st.title("Semi-Structured Data - XML Details")
|
| 53 |
+
st.markdown("""
|
| 54 |
+
**XML** (eXtensible Markup Language) stores data in a hierarchical structure.
|
| 55 |
+
|
| 56 |
+
- Uses tags to define data elements.
|
| 57 |
+
- Commonly used for web data and configuration files.
|
| 58 |
+
""")
|
| 59 |
+
st.code('import xml.etree.ElementTree as ET\ntree = ET.parse("file.xml")', language="python")
|
| 60 |
+
|
| 61 |
+
if st.button("Back to Home"):
|
| 62 |
+
st.session_state['page'] = "home"
|
| 63 |
+
|
| 64 |
+
# Semi-Structured Data - HTML Page
|
| 65 |
+
def html_details_page():
|
| 66 |
+
st.title("Semi-Structured Data - HTML Details")
|
| 67 |
+
st.markdown("""
|
| 68 |
+
**HTML** (HyperText Markup Language) is used to structure web pages.
|
| 69 |
+
|
| 70 |
+
- Semi-structured data with nested tags.
|
| 71 |
+
- Libraries like `BeautifulSoup` help parse and extract information.
|
| 72 |
+
""")
|
| 73 |
+
st.code('from bs4 import BeautifulSoup\nsoup = BeautifulSoup(open("file.html"))', language="python")
|
| 74 |
+
|
| 75 |
+
if st.button("Back to Home"):
|
| 76 |
+
st.session_state['page'] = "home"
|
| 77 |
+
|
| 78 |
+
# Unstructured Data - Image Page
|
| 79 |
+
def image_details_page():
|
| 80 |
+
st.title("Unstructured Data - Image Details")
|
| 81 |
+
st.markdown("""
|
| 82 |
+
**Images** are unstructured data represented in pixel values.
|
| 83 |
+
|
| 84 |
+
- Formats include JPEG, PNG, BMP, etc.
|
| 85 |
+
- Libraries like OpenCV and PIL are used for image processing.
|
| 86 |
+
""")
|
| 87 |
+
st.code('from PIL import Image\nimage = Image.open("file.jpg")', language="python")
|
| 88 |
+
|
| 89 |
+
if st.button("Back to Home"):
|
| 90 |
+
st.session_state['page'] = "home"
|
| 91 |
+
|
| 92 |
+
# Unstructured Data - Video Page
|
| 93 |
+
def video_details_page():
|
| 94 |
+
st.title("Unstructured Data - Video Details")
|
| 95 |
+
st.markdown("""
|
| 96 |
+
**Videos** are sequences of images with temporal data.
|
| 97 |
+
|
| 98 |
+
- Formats include MP4, AVI, MKV, etc.
|
| 99 |
+
- Libraries like OpenCV and MoviePy are used for video processing.
|
| 100 |
+
""")
|
| 101 |
+
st.code('import cv2\nvideo = cv2.VideoCapture("file.mp4")', language="python")
|
| 102 |
+
|
| 103 |
+
if st.button("Back to Home"):
|
| 104 |
+
st.session_state['page'] = "home"
|
| 105 |
+
|
| 106 |
+
# Main Page
|
| 107 |
+
|
| 108 |
+
def main_page():
|
| 109 |
+
st.title("Data Types")
|
| 110 |
+
|
| 111 |
+
data_type = st.radio("Select Data Type:", ["Structured", "Semi-Structured", "Unstructured"])
|
| 112 |
+
|
| 113 |
+
if data_type == "Structured":
|
| 114 |
if st.button("Excel"):
|
| 115 |
+
st.session_state['page'] = "excel"
|
| 116 |
+
|
| 117 |
+
elif data_type == "Semi-Structured":
|
| 118 |
+
st.write("Semi-Structured Data includes formats like CSV, JSON, XML, and HTML.")
|
| 119 |
+
|
| 120 |
+
if st.button("CSV"):
|
| 121 |
+
st.session_state['page'] = "csv"
|
| 122 |
+
if st.button("JSON"):
|
| 123 |
+
st.session_state['page'] = "json"
|
| 124 |
+
if st.button("XML"):
|
| 125 |
+
st.session_state['page'] = "xml"
|
| 126 |
+
if st.button("HTML"):
|
| 127 |
+
st.session_state['page'] = "html"
|
| 128 |
+
|
| 129 |
+
elif data_type == "Unstructured":
|
| 130 |
+
st.write("Unstructured Data includes formats like Images and Videos.")
|
| 131 |
+
|
|
|
|
|
|
|
|
|
|
| 132 |
if st.button("Image"):
|
| 133 |
+
st.session_state['page'] = "image"
|
| 134 |
if st.button("Video"):
|
| 135 |
+
st.session_state['page'] = "video"
|
| 136 |
+
|
| 137 |
+
# Initialize session state
|
| 138 |
+
if 'page' not in st.session_state:
|
| 139 |
+
st.session_state['page'] = "home"
|
| 140 |
|
| 141 |
+
# Route to appropriate page
|
| 142 |
+
if st.session_state['page'] == "home":
|
| 143 |
+
main_page()
|
| 144 |
+
elif st.session_state['page'] == "excel":
|
| 145 |
+
excel_details_page()
|
| 146 |
+
elif st.session_state['page'] == "csv":
|
| 147 |
+
csv_details_page()
|
| 148 |
+
elif st.session_state['page'] == "json":
|
| 149 |
+
json_details_page()
|
| 150 |
+
elif st.session_state['page'] == "xml":
|
| 151 |
+
xml_details_page()
|
| 152 |
+
elif st.session_state['page'] == "html":
|
| 153 |
+
html_details_page()
|
| 154 |
+
elif st.session_state['page'] == "image":
|
| 155 |
+
image_details_page()
|
| 156 |
+
elif st.session_state['page'] == "video":
|
| 157 |
+
video_details_page()
|