Update pages/3_Life Cycle Of ML Project.py
Browse files- pages/3_Life Cycle Of ML Project.py +113 -112
pages/3_Life Cycle Of ML Project.py
CHANGED
|
@@ -187,10 +187,10 @@ elif st.session_state.page == "unstructured_data":
|
|
| 187 |
|
| 188 |
# ----------------- Introduction to Image -----------------
|
| 189 |
elif st.session_state.page == "Introduction_to_image":
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
- **Raster Images (Bitmap)**: Composed of a grid of pixels. Common formats include:
|
| 195 |
- JPEG
|
| 196 |
- PNG
|
|
@@ -209,7 +209,7 @@ elif st.session_state.page == "Introduction_to_image":
|
|
| 209 |
- **Graphic Design & Art**: Creating creative visual content for marketing and design.
|
| 210 |
""")
|
| 211 |
|
| 212 |
-
|
| 213 |
from PIL import Image
|
| 214 |
import numpy as np
|
| 215 |
import matplotlib.pyplot as plt
|
|
@@ -235,8 +235,8 @@ elif st.session_state.page == "Introduction_to_image":
|
|
| 235 |
plt.show()
|
| 236 |
""", language='python')
|
| 237 |
|
| 238 |
-
|
| 239 |
-
|
| 240 |
A color space is a mathematical model for representing colors. In machine learning, different color spaces can be used for preprocessing and analyzing image data, depending on the task.
|
| 241 |
Common Color Spaces:
|
| 242 |
- **RGB (Red, Green, Blue)**: The most common color space for digital images. Each pixel is represented by a combination of three values corresponding to the red, green, and blue channels.
|
|
@@ -262,8 +262,8 @@ elif st.session_state.page == "Introduction_to_image":
|
|
| 262 |
|
| 263 |
elif st.session_state.page == "operations_using_opencv":
|
| 264 |
# Header and description for cv2.imread
|
| 265 |
-
|
| 266 |
-
|
| 267 |
**`cv2.imread()` - Read an Image**
|
| 268 |
**Purpose:** Load an image from a file and convert it to a NumPy array.
|
| 269 |
**Syntax:**
|
|
@@ -285,8 +285,8 @@ elif st.session_state.page == "operations_using_opencv":
|
|
| 285 |
""")
|
| 286 |
|
| 287 |
# Header and description for cv2.imshow
|
| 288 |
-
|
| 289 |
-
|
| 290 |
**`cv2.imshow()` - Display an Image**
|
| 291 |
**Purpose:** Show an image in a window.
|
| 292 |
**Syntax:**
|
|
@@ -309,8 +309,8 @@ elif st.session_state.page == "operations_using_opencv":
|
|
| 309 |
""")
|
| 310 |
|
| 311 |
# Header and description for cv2.imwrite
|
| 312 |
-
|
| 313 |
-
|
| 314 |
**`cv2.imwrite()` - Write/Save an Image**
|
| 315 |
**Purpose:** Save an image to a file.
|
| 316 |
**Syntax:**
|
|
@@ -346,9 +346,9 @@ elif st.session_state.page == "operations_using_opencv":
|
|
| 346 |
|
| 347 |
elif st.session_state.page == "operations_using_opencv":
|
| 348 |
# Header for Image Conversion
|
| 349 |
-
|
| 350 |
|
| 351 |
-
|
| 352 |
**OpenCV supports many color spaces for image processing.**
|
| 353 |
**Common Conversions:**
|
| 354 |
|
|
@@ -374,9 +374,9 @@ elif st.session_state.page == "operations_using_opencv":
|
|
| 374 |
""")
|
| 375 |
|
| 376 |
# Header for Splitting Channels
|
| 377 |
-
|
| 378 |
|
| 379 |
-
|
| 380 |
**Splitting an image into its individual color channels (B, G, R) allows you to analyze or modify each channel independently.**
|
| 381 |
**Syntax:**
|
| 382 |
```python
|
|
@@ -401,9 +401,9 @@ elif st.session_state.page == "operations_using_opencv":
|
|
| 401 |
""")
|
| 402 |
|
| 403 |
# Header for Merging Channels
|
| 404 |
-
|
| 405 |
|
| 406 |
-
|
| 407 |
**You can merge the individual channels back into a color image using `cv2.merge()`.**
|
| 408 |
**Syntax:**
|
| 409 |
```python
|
|
@@ -429,9 +429,9 @@ elif st.session_state.page == "operations_using_opencv":
|
|
| 429 |
""")
|
| 430 |
|
| 431 |
# Header for Combining with Modifications
|
| 432 |
-
|
| 433 |
|
| 434 |
-
|
| 435 |
**You can modify each channel (e.g., increase brightness in the red channel) before merging them back together.**
|
| 436 |
**Example:**
|
| 437 |
```python
|
|
@@ -470,9 +470,9 @@ elif st.session_state.page == "operations_using_opencv":
|
|
| 470 |
|
| 471 |
elif st.session_state.page == "Video_capture_and_explanation_page":
|
| 472 |
|
| 473 |
-
|
| 474 |
|
| 475 |
-
|
| 476 |
**Purpose**: Captures live video from a webcam or reads a video file using OpenCV.
|
| 477 |
### Syntax
|
| 478 |
```python
|
|
@@ -516,8 +516,8 @@ elif st.session_state.page == "Video_capture_and_explanation_page":
|
|
| 516 |
|
| 517 |
##----------##
|
| 518 |
|
| 519 |
-
|
| 520 |
-
|
| 521 |
Purpose:
|
| 522 |
cv2.waitKey() is a key function used to handle keyboard events in OpenCV. It is commonly used to display images or video frames and wait for a user input.
|
| 523 |
Syntax:
|
|
@@ -570,7 +570,7 @@ elif st.session_state.page == "Video_capture_and_explanation_page":
|
|
| 570 |
|
| 571 |
###------KEY POINTS -----###
|
| 572 |
|
| 573 |
-
|
| 574 |
1. **Video Capture (`cv2.VideoCapture`)**: Opens and reads video either from the webcam or from a video file.
|
| 575 |
- **Method `cap.read()`**: Captures individual frames from the video source.
|
| 576 |
- **Releasing the capture (`cap.release()`)**: Ensures that the resources are freed once done.
|
|
@@ -604,10 +604,10 @@ This explanation provides both the purpose and practical use cases of `cv2.Video
|
|
| 604 |
|
| 605 |
elif st.session_state.page == "affine_transformation_matrix":
|
| 606 |
# Header for Affine Transformation Matrix
|
| 607 |
-
|
| 608 |
|
| 609 |
# Description of Affine Transformation
|
| 610 |
-
|
| 611 |
An **Affine Transformation** is a linear mapping method that preserves points, straight lines, and planes. In other words, it maintains the structure of the original object while allowing for operations like translation, scaling, rotation, reflection, and shearing. Affine transformations are widely used in computer graphics, computer vision, image processing, and geometry.
|
| 612 |
Affine transformations can be represented by a **transformation matrix** of the following form:
|
| 613 |
\\[
|
|
@@ -627,9 +627,9 @@ elif st.session_state.page == "affine_transformation_matrix":
|
|
| 627 |
""")
|
| 628 |
|
| 629 |
# Key Points Section
|
| 630 |
-
|
| 631 |
|
| 632 |
-
|
| 633 |
### 1. **Preserves Collinearity**
|
| 634 |
- Points that lie on a straight line before transformation remain on a straight line after transformation.
|
| 635 |
### 2. **Preserves Ratios of Distances**
|
|
@@ -670,8 +670,8 @@ elif st.session_state.page == "affine_transformation_matrix":
|
|
| 670 |
|
| 671 |
# ----------------- Semi-Structured Data Page -----------------
|
| 672 |
elif st.session_state.page == "semi_structured_data":
|
| 673 |
-
|
| 674 |
-
|
| 675 |
Semi-structured data does not have a rigid structure but contains tags and markers to separate different data elements, like XML or JSON.
|
| 676 |
""")
|
| 677 |
|
|
@@ -693,42 +693,43 @@ elif st.session_state.page == "semi_structured_data":
|
|
| 693 |
|
| 694 |
# ----------------- CSV Data Page -----------------
|
| 695 |
elif st.session_state.page == "csv":
|
| 696 |
-
|
| 697 |
-
|
| 698 |
CSV (Comma-Separated Values) is a simple format used to store tabular data. Each line in the file represents a row, and commas separate the values within the row.
|
| 699 |
""")
|
| 700 |
-
|
| 701 |
-
|
| 702 |
import pandas as pd
|
| 703 |
# Read a CSV file
|
| 704 |
df = pd.read_csv('data.csv')
|
| 705 |
print(df)
|
| 706 |
""", language='python')
|
| 707 |
|
| 708 |
-
|
| 709 |
-
|
| 710 |
- *File not found*: Incorrect file path.
|
| 711 |
- *Wrong delimiter*: The CSV uses a different delimiter (e.g., semicolon).
|
| 712 |
- *Missing Libraries*: pandas might be missing.
|
| 713 |
""")
|
| 714 |
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
# Install required libraries
|
| 718 |
-
# pip install pandas
|
| 719 |
-
# Handle file not found
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
st.
|
|
|
|
| 732 |
|
| 733 |
|
| 734 |
|
|
@@ -740,14 +741,14 @@ elif st.session_state.page == "xml":
|
|
| 740 |
""")
|
| 741 |
st.markdown("### Example: Reading XML data")
|
| 742 |
st.code("""
|
| 743 |
-
import xml.etree.ElementTree as ET
|
| 744 |
-
|
| 745 |
-
tree = ET.parse('data.xml')
|
| 746 |
-
root = tree.getroot()
|
| 747 |
-
|
| 748 |
-
for elem in root:
|
| 749 |
-
|
| 750 |
-
|
| 751 |
|
| 752 |
st.write("### Issues Encountered")
|
| 753 |
st.write("""
|
|
@@ -756,12 +757,12 @@ for elem in root:
|
|
| 756 |
|
| 757 |
st.write("### Solutions to These Issues")
|
| 758 |
st.code("""
|
| 759 |
-
try:
|
| 760 |
-
|
| 761 |
-
|
| 762 |
-
except FileNotFoundError:
|
| 763 |
-
|
| 764 |
-
|
| 765 |
|
| 766 |
st.link_button(":blue[Jupyter Notebook(colab)]","https://colab.research.google.com/drive/1jXSPACETyJ5OMKx7Nhx2Mn75V9n9WIyY?usp=sharing")
|
| 767 |
|
|
@@ -778,28 +779,28 @@ elif st.session_state.page == "json":
|
|
| 778 |
|
| 779 |
st.markdown("### Example: Reading JSON data")
|
| 780 |
st.code("""
|
| 781 |
-
import json
|
| 782 |
-
|
| 783 |
-
# Reading a JSON file
|
| 784 |
-
with open('data.json', 'r') as file:
|
| 785 |
-
data = json.load(file)
|
| 786 |
-
|
| 787 |
-
print(data)
|
| 788 |
-
""", language='python')
|
| 789 |
-
|
| 790 |
-
st.write("### Issues Encountered")
|
| 791 |
-
st.write("""
|
| 792 |
-
- *File not found*: Incorrect file path.
|
| 793 |
-
""")
|
| 794 |
-
|
| 795 |
-
st.write("### Solutions to These Issues")
|
| 796 |
-
st.code("""
|
| 797 |
-
try:
|
| 798 |
with open('data.json', 'r') as file:
|
| 799 |
data = json.load(file)
|
| 800 |
-
|
| 801 |
-
print(
|
| 802 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 803 |
|
| 804 |
st.link_button(":blue[Jupyter Notebook(colab)]","https://colab.research.google.com/drive/12VF_YSzYvILWHOHKQQu2SeytOLSooN7K?usp=sharing")
|
| 805 |
|
|
@@ -813,31 +814,31 @@ elif st.session_state.page == "html":
|
|
| 813 |
HTML (HyperText Markup Language) is the standard language for creating webpages. It uses a markup structure to format text, images, and other content on the web.
|
| 814 |
""")
|
| 815 |
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
import pandas as pd
|
| 819 |
-
|
| 820 |
-
# Reading HTML data
|
| 821 |
-
dfs = pd.read_html('sample.html')
|
| 822 |
-
print(dfs[0]) # Display the first table from the HTML file
|
| 823 |
-
|
| 824 |
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
|
| 830 |
|
| 831 |
-
|
| 832 |
-
|
| 833 |
-
# Install required libraries
|
| 834 |
-
# pip install pandas
|
| 835 |
-
# Handle file not found
|
| 836 |
-
try:
|
| 837 |
-
|
| 838 |
-
except FileNotFoundError:
|
| 839 |
-
|
| 840 |
-
|
| 841 |
|
| 842 |
st.link_button(":blue[Jupyter Notebook(colab)]","https://colab.research.google.com/drive/1yBgo4h_RNlc2KJApxXEWZXEZCwWHos_n?usp=sharing")
|
| 843 |
|
|
|
|
| 187 |
|
| 188 |
# ----------------- Introduction to Image -----------------
|
| 189 |
elif st.session_state.page == "Introduction_to_image":
|
| 190 |
+
st.header("🖼️ What is Image")
|
| 191 |
+
st.markdown("""
|
| 192 |
+
###: What is an image?\nAn image is a two-dimensional visual representation of objects, people, scenes, or concepts. It can be captured using devices like cameras, scanners, or created digitally. Images are composed of individual units called pixels, which contain information about brightness and color.
|
| 193 |
+
Types of Images:
|
| 194 |
- **Raster Images (Bitmap)**: Composed of a grid of pixels. Common formats include:
|
| 195 |
- JPEG
|
| 196 |
- PNG
|
|
|
|
| 209 |
- **Graphic Design & Art**: Creating creative visual content for marketing and design.
|
| 210 |
""")
|
| 211 |
|
| 212 |
+
st.code("""
|
| 213 |
from PIL import Image
|
| 214 |
import numpy as np
|
| 215 |
import matplotlib.pyplot as plt
|
|
|
|
| 235 |
plt.show()
|
| 236 |
""", language='python')
|
| 237 |
|
| 238 |
+
st.header("Color Spaces in Machine Learning")
|
| 239 |
+
st.markdown("""
|
| 240 |
A color space is a mathematical model for representing colors. In machine learning, different color spaces can be used for preprocessing and analyzing image data, depending on the task.
|
| 241 |
Common Color Spaces:
|
| 242 |
- **RGB (Red, Green, Blue)**: The most common color space for digital images. Each pixel is represented by a combination of three values corresponding to the red, green, and blue channels.
|
|
|
|
| 262 |
|
| 263 |
elif st.session_state.page == "operations_using_opencv":
|
| 264 |
# Header and description for cv2.imread
|
| 265 |
+
st.header("🗂️ Reading an Image with cv2.imread()")
|
| 266 |
+
st.markdown("""
|
| 267 |
**`cv2.imread()` - Read an Image**
|
| 268 |
**Purpose:** Load an image from a file and convert it to a NumPy array.
|
| 269 |
**Syntax:**
|
|
|
|
| 285 |
""")
|
| 286 |
|
| 287 |
# Header and description for cv2.imshow
|
| 288 |
+
st.header("🖼️ Displaying an Image with cv2.imshow()")
|
| 289 |
+
st.markdown("""
|
| 290 |
**`cv2.imshow()` - Display an Image**
|
| 291 |
**Purpose:** Show an image in a window.
|
| 292 |
**Syntax:**
|
|
|
|
| 309 |
""")
|
| 310 |
|
| 311 |
# Header and description for cv2.imwrite
|
| 312 |
+
st.header("💾 Saving an Image with cv2.imwrite()")
|
| 313 |
+
st.markdown("""
|
| 314 |
**`cv2.imwrite()` - Write/Save an Image**
|
| 315 |
**Purpose:** Save an image to a file.
|
| 316 |
**Syntax:**
|
|
|
|
| 346 |
|
| 347 |
elif st.session_state.page == "operations_using_opencv":
|
| 348 |
# Header for Image Conversion
|
| 349 |
+
st.header("🔄 Converting Images Between Different Color Spaces")
|
| 350 |
|
| 351 |
+
st.markdown("""
|
| 352 |
**OpenCV supports many color spaces for image processing.**
|
| 353 |
**Common Conversions:**
|
| 354 |
|
|
|
|
| 374 |
""")
|
| 375 |
|
| 376 |
# Header for Splitting Channels
|
| 377 |
+
st.header("🔹 Splitting Color Channels in an Image")
|
| 378 |
|
| 379 |
+
st.markdown("""
|
| 380 |
**Splitting an image into its individual color channels (B, G, R) allows you to analyze or modify each channel independently.**
|
| 381 |
**Syntax:**
|
| 382 |
```python
|
|
|
|
| 401 |
""")
|
| 402 |
|
| 403 |
# Header for Merging Channels
|
| 404 |
+
st.header("🔹 Merging Color Channels in an Image")
|
| 405 |
|
| 406 |
+
st.markdown("""
|
| 407 |
**You can merge the individual channels back into a color image using `cv2.merge()`.**
|
| 408 |
**Syntax:**
|
| 409 |
```python
|
|
|
|
| 429 |
""")
|
| 430 |
|
| 431 |
# Header for Combining with Modifications
|
| 432 |
+
st.header("🎨 Modifying Channels Before Merging")
|
| 433 |
|
| 434 |
+
st.markdown("""
|
| 435 |
**You can modify each channel (e.g., increase brightness in the red channel) before merging them back together.**
|
| 436 |
**Example:**
|
| 437 |
```python
|
|
|
|
| 470 |
|
| 471 |
elif st.session_state.page == "Video_capture_and_explanation_page":
|
| 472 |
|
| 473 |
+
st.header("🎥 Video Capture with `cv2.VideoCapture()`")
|
| 474 |
|
| 475 |
+
st.markdown("""
|
| 476 |
**Purpose**: Captures live video from a webcam or reads a video file using OpenCV.
|
| 477 |
### Syntax
|
| 478 |
```python
|
|
|
|
| 516 |
|
| 517 |
##----------##
|
| 518 |
|
| 519 |
+
st.header("⏱️ cv2.waitKey() for Key Event Handling")
|
| 520 |
+
st.markdown("""
|
| 521 |
Purpose:
|
| 522 |
cv2.waitKey() is a key function used to handle keyboard events in OpenCV. It is commonly used to display images or video frames and wait for a user input.
|
| 523 |
Syntax:
|
|
|
|
| 570 |
|
| 571 |
###------KEY POINTS -----###
|
| 572 |
|
| 573 |
+
st.markdown("""
|
| 574 |
1. **Video Capture (`cv2.VideoCapture`)**: Opens and reads video either from the webcam or from a video file.
|
| 575 |
- **Method `cap.read()`**: Captures individual frames from the video source.
|
| 576 |
- **Releasing the capture (`cap.release()`)**: Ensures that the resources are freed once done.
|
|
|
|
| 604 |
|
| 605 |
elif st.session_state.page == "affine_transformation_matrix":
|
| 606 |
# Header for Affine Transformation Matrix
|
| 607 |
+
st.header("Affine Transformation Matrix")
|
| 608 |
|
| 609 |
# Description of Affine Transformation
|
| 610 |
+
st.markdown("""
|
| 611 |
An **Affine Transformation** is a linear mapping method that preserves points, straight lines, and planes. In other words, it maintains the structure of the original object while allowing for operations like translation, scaling, rotation, reflection, and shearing. Affine transformations are widely used in computer graphics, computer vision, image processing, and geometry.
|
| 612 |
Affine transformations can be represented by a **transformation matrix** of the following form:
|
| 613 |
\\[
|
|
|
|
| 627 |
""")
|
| 628 |
|
| 629 |
# Key Points Section
|
| 630 |
+
st.header("Key Points of Affine Transformations")
|
| 631 |
|
| 632 |
+
st.markdown("""
|
| 633 |
### 1. **Preserves Collinearity**
|
| 634 |
- Points that lie on a straight line before transformation remain on a straight line after transformation.
|
| 635 |
### 2. **Preserves Ratios of Distances**
|
|
|
|
| 670 |
|
| 671 |
# ----------------- Semi-Structured Data Page -----------------
|
| 672 |
elif st.session_state.page == "semi_structured_data":
|
| 673 |
+
st.title(":blue[Semi-Structured Data]")
|
| 674 |
+
st.markdown("""
|
| 675 |
Semi-structured data does not have a rigid structure but contains tags and markers to separate different data elements, like XML or JSON.
|
| 676 |
""")
|
| 677 |
|
|
|
|
| 693 |
|
| 694 |
# ----------------- CSV Data Page -----------------
|
| 695 |
elif st.session_state.page == "csv":
|
| 696 |
+
st.title(":red[CSV Data Format]")
|
| 697 |
+
st.markdown("""
|
| 698 |
CSV (Comma-Separated Values) is a simple format used to store tabular data. Each line in the file represents a row, and commas separate the values within the row.
|
| 699 |
""")
|
| 700 |
+
st.markdown("### How to Read a CSV file")
|
| 701 |
+
st.code("""
|
| 702 |
import pandas as pd
|
| 703 |
# Read a CSV file
|
| 704 |
df = pd.read_csv('data.csv')
|
| 705 |
print(df)
|
| 706 |
""", language='python')
|
| 707 |
|
| 708 |
+
st.markdown("### Issues Encountered")
|
| 709 |
+
st.write("""
|
| 710 |
- *File not found*: Incorrect file path.
|
| 711 |
- *Wrong delimiter*: The CSV uses a different delimiter (e.g., semicolon).
|
| 712 |
- *Missing Libraries*: pandas might be missing.
|
| 713 |
""")
|
| 714 |
|
| 715 |
+
st.write("### Solutions")
|
| 716 |
+
st.code("""
|
| 717 |
+
# Install required libraries
|
| 718 |
+
# pip install pandas
|
| 719 |
+
# Handle file not found
|
| 720 |
+
|
| 721 |
+
try:
|
| 722 |
+
df = pd.read_csv('data.csv')
|
| 723 |
+
except FileNotFoundError:
|
| 724 |
+
print("File not found. Check the file path.")
|
| 725 |
+
# Handle incorrect delimiter
|
| 726 |
+
df = pd.read_csv('data.csv', delimiter=';')
|
| 727 |
+
""", language='python')
|
| 728 |
+
st.link_button(":blue[Jupyter Notebook(colab)]","https://colab.research.google.com/drive/10MHcHTn40RcRA80TMvyXLiIwmU94Nt4N?usp=sharing")
|
| 729 |
+
|
| 730 |
+
|
| 731 |
+
if st.button(":red[Back to Structured Data]"):
|
| 732 |
+
st.session_state.page = "structured_data"
|
| 733 |
|
| 734 |
|
| 735 |
|
|
|
|
| 741 |
""")
|
| 742 |
st.markdown("### Example: Reading XML data")
|
| 743 |
st.code("""
|
| 744 |
+
import xml.etree.ElementTree as ET
|
| 745 |
+
|
| 746 |
+
tree = ET.parse('data.xml')
|
| 747 |
+
root = tree.getroot()
|
| 748 |
+
|
| 749 |
+
for elem in root:
|
| 750 |
+
print(elem.tag, elem.text)
|
| 751 |
+
""", language='python')
|
| 752 |
|
| 753 |
st.write("### Issues Encountered")
|
| 754 |
st.write("""
|
|
|
|
| 757 |
|
| 758 |
st.write("### Solutions to These Issues")
|
| 759 |
st.code("""
|
| 760 |
+
try:
|
| 761 |
+
tree = ET.parse('data.xml')
|
| 762 |
+
root = tree.getroot()
|
| 763 |
+
except FileNotFoundError:
|
| 764 |
+
print("File not found. Check the file path.")
|
| 765 |
+
""", language='python')
|
| 766 |
|
| 767 |
st.link_button(":blue[Jupyter Notebook(colab)]","https://colab.research.google.com/drive/1jXSPACETyJ5OMKx7Nhx2Mn75V9n9WIyY?usp=sharing")
|
| 768 |
|
|
|
|
| 779 |
|
| 780 |
st.markdown("### Example: Reading JSON data")
|
| 781 |
st.code("""
|
| 782 |
+
import json
|
| 783 |
+
|
| 784 |
+
# Reading a JSON file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 785 |
with open('data.json', 'r') as file:
|
| 786 |
data = json.load(file)
|
| 787 |
+
|
| 788 |
+
print(data)
|
| 789 |
+
""", language='python')
|
| 790 |
+
|
| 791 |
+
st.write("### Issues Encountered")
|
| 792 |
+
st.write("""
|
| 793 |
+
- *File not found*: Incorrect file path.
|
| 794 |
+
""")
|
| 795 |
+
|
| 796 |
+
st.write("### Solutions to These Issues")
|
| 797 |
+
st.code("""
|
| 798 |
+
try:
|
| 799 |
+
with open('data.json', 'r') as file:
|
| 800 |
+
data = json.load(file)
|
| 801 |
+
except FileNotFoundError:
|
| 802 |
+
print("File not found. Check the file path.")
|
| 803 |
+
""", language='python')
|
| 804 |
|
| 805 |
st.link_button(":blue[Jupyter Notebook(colab)]","https://colab.research.google.com/drive/12VF_YSzYvILWHOHKQQu2SeytOLSooN7K?usp=sharing")
|
| 806 |
|
|
|
|
| 814 |
HTML (HyperText Markup Language) is the standard language for creating webpages. It uses a markup structure to format text, images, and other content on the web.
|
| 815 |
""")
|
| 816 |
|
| 817 |
+
st.markdown("### Example: Reading HTML data")
|
| 818 |
+
st.code("""
|
| 819 |
+
import pandas as pd
|
| 820 |
+
|
| 821 |
+
# Reading HTML data
|
| 822 |
+
dfs = pd.read_html('sample.html')
|
| 823 |
+
print(dfs[0]) # Display the first table from the HTML file
|
| 824 |
+
""", language='python')
|
| 825 |
|
| 826 |
+
st.write("### Issues Encountered")
|
| 827 |
+
st.write("""
|
| 828 |
+
- *File not found*: Incorrect file path.
|
| 829 |
+
- *Missing Libraries*: pandas might be missing.
|
| 830 |
+
""")
|
| 831 |
|
| 832 |
+
st.write("### Solutions to These Issues")
|
| 833 |
+
st.code("""
|
| 834 |
+
# Install required libraries
|
| 835 |
+
# pip install pandas
|
| 836 |
+
# Handle file not found
|
| 837 |
+
try:
|
| 838 |
+
dfs = pd.read_html('sample.html')
|
| 839 |
+
except FileNotFoundError:
|
| 840 |
+
print("File not found. Check the file path.")
|
| 841 |
+
""", language='python')
|
| 842 |
|
| 843 |
st.link_button(":blue[Jupyter Notebook(colab)]","https://colab.research.google.com/drive/1yBgo4h_RNlc2KJApxXEWZXEZCwWHos_n?usp=sharing")
|
| 844 |
|