LakshmiHarika commited on
Commit
eaf9a60
·
verified ·
1 Parent(s): 9e2f35d

Update pages/Data Collection.py

Browse files
Files changed (1) hide show
  1. pages/Data Collection.py +125 -6
pages/Data Collection.py CHANGED
@@ -1846,8 +1846,6 @@ elif st.session_state.current_page == "explore_csv":
1846
  """, unsafe_allow_html=True)
1847
 
1848
  st.code("""
1849
- import pandas as pd
1850
-
1851
  # Sample DataFrame
1852
  data = pd.DataFrame({
1853
  'sepal_length': [1.5, 1.4, 1.5],
@@ -1983,14 +1981,135 @@ elif st.session_state.current_page == "explore_json":
1983
 
1984
  elif st.session_state.current_page == "explore_xml":
1985
  st.markdown("""
1986
- <h3 style="color: #e25822;">Exploring XML</h3>
1987
  """, unsafe_allow_html=True)
 
1988
  st.write("""
1989
- XML uses tags to structure semi-structured data.
 
 
 
 
 
 
1990
  """)
1991
- if st.button("Go Back"):
1992
- navigate_to("main")
1993
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1994
 
1995
  #--------------------------------------------------------- HTML --------------------------------------------------------------------------------
1996
 
 
1846
  """, unsafe_allow_html=True)
1847
 
1848
  st.code("""
 
 
1849
  # Sample DataFrame
1850
  data = pd.DataFrame({
1851
  'sepal_length': [1.5, 1.4, 1.5],
 
1981
 
1982
  elif st.session_state.current_page == "explore_xml":
1983
  st.markdown("""
1984
+ <h3 style="color: #BB3385;">Extensible Markup Language(XML)</h3>
1985
  """, unsafe_allow_html=True)
1986
+
1987
  st.write("""
1988
+ - **XML (Extensible Markup Language)** is a markup language used to store and transport data.
1989
+ - It is designed to be self-descriptive, making it easy to read and understand.
1990
+ - XML uses a tree structure where data is organized into nested elements.
1991
+ - Commonly used for:
1992
+ - Configuration files
1993
+ - Data interchange between systems
1994
+ - Storing structured data
1995
  """)
 
 
1996
 
1997
+ st.markdown("""
1998
+ <h3 style="color: #5b2c6f;">Element-wise XML Structure</h3>
1999
+ """, unsafe_allow_html=True)
2000
+
2001
+ st.write("""
2002
+ An element-wise XML structure organizes data into nested elements, where each piece of information is an individual element.""")
2003
+
2004
+ st.code("""
2005
+ <items>
2006
+ <item>
2007
+ <name>Item 1</name>
2008
+ <price>100</price>
2009
+ <category>Category A</category>
2010
+ </item>
2011
+ <item>
2012
+ <name>Item 2</name>
2013
+ <price>200</price>
2014
+ <category>Category B</category>
2015
+ </item>
2016
+ </items>
2017
+ """, language="xml")
2018
+
2019
+ st.code("""
2020
+
2021
+ # Reading an element-wise XML file
2022
+ df = pd.read_xml('element_structure.xml', xpath='/items/item')
2023
+ print(df)
2024
+ """, language="python")
2025
+
2026
+ st.write("""
2027
+ **Output DataFrame**:
2028
+ """)
2029
+
2030
+ st.table({
2031
+ 'name': ['Item 1', 'Item 2'],
2032
+ 'price': [100, 200],
2033
+ 'category': ['Category A', 'Category B']
2034
+ })
2035
+
2036
+ st.write("""
2037
+ ### Explanation of the `xpath` Parameter:
2038
+ - `xpath='/items/item'`: Extracts all `<item>` elements from within `<items>`.
2039
+ - Useful for XML structures with data organized by child elements.
2040
+ """)
2041
+
2042
+
2043
+ st.markdown("""
2044
+ <h3 style="color: #5b2c6f;">Attribute XML Structure</h3>
2045
+ """, unsafe_allow_html=True)
2046
+
2047
+ st.write("""
2048
+ An attribute XML structure stores data as attributes of tags, rather than as child elements.""")
2049
+
2050
+ st.code("""
2051
+ <items>
2052
+ <item name="Item 1" price="100" category="Category A" />
2053
+ <item name="Item 2" price="200" category="Category B" />
2054
+ </items>
2055
+ """, language="xml")
2056
+
2057
+ st.code("""
2058
+
2059
+ # Reading an attribute-based XML file
2060
+ df = pd.read_xml('attribute_structure.xml', xpath='/items/item')
2061
+ print(df)
2062
+ """, language="python")
2063
+
2064
+ st.write("""
2065
+ **Output DataFrame**:
2066
+ """)
2067
+
2068
+ st.table({
2069
+ 'name': ['Item 1', 'Item 2'],
2070
+ 'price': [100, 200],
2071
+ 'category': ['Category A', 'Category B']
2072
+ })
2073
+
2074
+ st.write("""
2075
+ ### Explanation of the `xpath` Parameter:
2076
+ - `xpath='/items/item'`: Extracts attributes of `<item>` elements.
2077
+ - Useful for XML structures where data is stored in attributes instead of nested elements.
2078
+ """)
2079
+
2080
+ st.markdown("""
2081
+ <h3 style="color: #5b2c6f;">Exporting Element-wise XML Structure</h3>
2082
+ """, unsafe_allow_html=True)
2083
+
2084
+ st.code("""
2085
+
2086
+ # Sample DataFrame
2087
+ data = pd.DataFrame({
2088
+ 'name': ['Item 1', 'Item 2'],
2089
+ 'price': [100, 200],
2090
+ 'category': ['Category A', 'Category B']
2091
+ })
2092
+
2093
+ # Export the DataFrame to an element-wise XML file
2094
+ data.to_xml('element_structure.xml', index=False, root_name='items', row_name='item')
2095
+ """, language="python")
2096
+
2097
+ st.markdown("""
2098
+ <h3 style="color: #5b2c6f;">Exporting Attribute XML Structure</h3>
2099
+ """, unsafe_allow_html=True)
2100
+
2101
+ st.code("""
2102
+
2103
+ # Sample DataFrame
2104
+ data = pd.DataFrame({
2105
+ 'name': ['Item 1', 'Item 2'],
2106
+ 'price': [100, 200],
2107
+ 'category': ['Category A', 'Category B']
2108
+ })
2109
+
2110
+ # Export the DataFrame to an attribute-based XML file
2111
+ data.to_xml('attribute_structure.xml', index=False, root_name='items', row_name='item', attr_cols=['name', 'price', 'category'])
2112
+ """, language="python")
2113
 
2114
  #--------------------------------------------------------- HTML --------------------------------------------------------------------------------
2115