Spaces:
Sleeping
Sleeping
Update pages/hari.py
Browse files- pages/hari.py +29 -6
pages/hari.py
CHANGED
|
@@ -6,14 +6,37 @@ import pandas as pd
|
|
| 6 |
# Structured Data - Excel Page
|
| 7 |
def excel_details_page():
|
| 8 |
st.title("Structured Data - Excel Details")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
st.markdown("""
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
""
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
if st.button("Back to Home"):
|
| 19 |
st.session_state['page'] = "home"
|
|
|
|
| 6 |
# Structured Data - Excel Page
|
| 7 |
def excel_details_page():
|
| 8 |
st.title("Structured Data - Excel Details")
|
| 9 |
+
|
| 10 |
+
st.markdown("<h3 style='text-align:; color: #4a90e2;'>1. Handling Excel Files (.xlsx)</h3>", unsafe_allow_html=True)
|
| 11 |
+
st.markdown("""
|
| 12 |
+
<ul style="font-family: Arial; line-height: 1.6;">
|
| 13 |
+
<li>Excel Files are (XLSX) Created using the Microsoft Excel application.</li>
|
| 14 |
+
<li>Structured data format.</li>
|
| 15 |
+
<li>Excel files automatically handle encoding during creation, so no encoding issues arise.</li>
|
| 16 |
+
<li>If there are extra values in a row, Excel creates a new column and fills it with <b>null values</b> instead of throwing a <b>parsing error</b>.</li>
|
| 17 |
+
</ul>
|
| 18 |
+
""", unsafe_allow_html=True)
|
| 19 |
+
|
| 20 |
+
st.markdown("<h3 style='text-align:; color: #ffa500;'>2. Reading Excel Files (.xlsx)</h3>", unsafe_allow_html=True)
|
| 21 |
st.markdown("""
|
| 22 |
+
<ul style="font-family: Arial; line-height: 1.6;">
|
| 23 |
+
<li>Use the <b>pandas</b> function, <b>pd.read_excel("path")</b>, to read an Excel file.</li>
|
| 24 |
+
<li>By default, it reads only one sheet.</li>
|
| 25 |
+
<li>To read multiple sheets, specify the <b>sheet_name</b> parameter with a list of sheet indices.</li>
|
| 26 |
+
</ul>""", unsafe_allow_html=True)
|
| 27 |
|
| 28 |
+
st.code('df = pd.read_excel("path", sheet_name=[0, 1, 2])', language="python")
|
| 29 |
+
|
| 30 |
+
st.markdown("""
|
| 31 |
+
<ul style="font-family: Arial; line-height: 1.6;">
|
| 32 |
+
<li><b>The Result is a Dictionary</b></li>
|
| 33 |
+
<li>Keys: Sheet names.</li>
|
| 34 |
+
<li>Values: DataFrames corresponding to each sheet.</li>
|
| 35 |
+
</ul>""", unsafe_allow_html=True)
|
| 36 |
+
|
| 37 |
+
st.code('df_first_sheet = df[0] # First sheet\n'
|
| 38 |
+
'df_second_sheet = df[1] # Second sheet\n'
|
| 39 |
+
'df_third_sheet = df[2] # Third sheet', language="english")
|
| 40 |
|
| 41 |
if st.button("Back to Home"):
|
| 42 |
st.session_state['page'] = "home"
|