sree4411 commited on
Commit
a55bc59
·
verified ·
1 Parent(s): 1fcc334

Update pages/3_Life Cycle Of ML Project.py

Browse files
Files changed (1) hide show
  1. pages/3_Life Cycle Of ML Project.py +51 -0
pages/3_Life Cycle Of ML Project.py CHANGED
@@ -262,3 +262,54 @@ data = '''
262
  "age": 25,
263
  "skills": ["Python", "Machine Learning"]
264
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  "age": 25,
263
  "skills": ["Python", "Machine Learning"]
264
  }
265
+ '''
266
+
267
+ # Parse JSON
268
+ parsed_data = json.loads(data)
269
+ print(parsed_data['name']) # Output: Alice
270
+ """, language='python')
271
+
272
+ st.header("🔹 Reading JSON Files")
273
+ st.code("""
274
+ # Reading a JSON file
275
+ with open('data.json', 'r') as file:
276
+ data = json.load(file)
277
+ print(data)
278
+ """, language='python')
279
+
280
+ st.header("🔹 XML Data")
281
+ st.markdown("""
282
+ XML is a markup language that defines a set of rules for encoding documents.
283
+ """)
284
+ st.code("""
285
+ import xml.etree.ElementTree as ET
286
+
287
+ # Sample XML data
288
+ xml_data = '''
289
+ <person>
290
+ <name>Bob</name>
291
+ <age>30</age>
292
+ <city>New York</city>
293
+ </person>
294
+ '''
295
+
296
+ # Parse XML
297
+ root = ET.fromstring(xml_data)
298
+ print(root.find('name').text) # Output: Bob
299
+ """, language='python')
300
+
301
+ st.markdown("### Challenges with Semi-Structured Data")
302
+ st.write("""
303
+ - **Complex Parsing**: Requires specialized parsers.
304
+ - **Nested Data**: Can be deeply nested, making it harder to process.
305
+ """)
306
+
307
+ st.markdown("### Solutions")
308
+ st.write("""
309
+ - **Libraries**: Use libraries like json, xml.etree.ElementTree, and yaml for parsing.
310
+ - **Validation**: Validate data formats to avoid parsing errors.
311
+ """)
312
+
313
+ # Back to Data Collection
314
+ if st.button("Back to Data Collection"):
315
+ st.session_state.page = "data_collection"