Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,53 +1,24 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import requests
|
| 3 |
import streamlit as st
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
st.
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
def show_tariff_input():
|
| 28 |
-
# Display tariff rates selection
|
| 29 |
-
tariff_data = pd.read_csv("data/tariffs.csv")
|
| 30 |
-
tariff_types = tariff_data["category"].unique()
|
| 31 |
-
tariff_choice = st.selectbox("Select your tariff category:", tariff_types)
|
| 32 |
-
st.write(f"Selected Tariff: {tariff_choice}")
|
| 33 |
-
|
| 34 |
-
def scrape_data():
|
| 35 |
-
# Scraping tariff data using provided URLs
|
| 36 |
-
scrape_tariffs(list(tariff_urls.values()))
|
| 37 |
-
|
| 38 |
-
# Streamlit actions
|
| 39 |
-
if st.sidebar.button("Scrape Data"):
|
| 40 |
-
scrape_data()
|
| 41 |
-
|
| 42 |
-
if st.sidebar.button("Download Model"):
|
| 43 |
-
download_model()
|
| 44 |
-
|
| 45 |
-
# User inputs for appliance and usage time (replace placeholders as needed)
|
| 46 |
-
appliance_load = st.number_input("Enter appliance load in watts", min_value=10, max_value=5000, value=1000)
|
| 47 |
-
usage_time = st.number_input("Enter usage time (in hours)", min_value=1, max_value=24, value=5)
|
| 48 |
-
|
| 49 |
-
# Placeholder for electricity bill calculation and output display
|
| 50 |
-
if appliance_load and usage_time:
|
| 51 |
-
bill_amount = appliance_load * usage_time * 0.25 # Add your own calculation based on tariffs
|
| 52 |
-
st.write(f"Your electricity bill: {bill_amount} PKR")
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from tariff_scraper import TARIFF_URLS, scrape_tariff_data
|
| 3 |
+
|
| 4 |
+
def main():
|
| 5 |
+
st.title("PESCO Tariff Rates Viewer")
|
| 6 |
+
st.write("This app fetches and displays the latest PESCO tariff rates.")
|
| 7 |
+
|
| 8 |
+
# Display the fetch button
|
| 9 |
+
if st.button("Fetch PESCO Tariff Rates"):
|
| 10 |
+
url = TARIFF_URLS["PESCO"]
|
| 11 |
+
st.write(f"Fetching data from {url}...")
|
| 12 |
+
|
| 13 |
+
with st.spinner("Scraping data..."):
|
| 14 |
+
data = scrape_tariff_data(url)
|
| 15 |
+
if data and isinstance(data, list) and len(data) > 0:
|
| 16 |
+
st.success("Data fetched successfully!")
|
| 17 |
+
st.write("### Tariff Rates:")
|
| 18 |
+
for row in data:
|
| 19 |
+
st.write(row)
|
| 20 |
+
else:
|
| 21 |
+
st.error("Failed to fetch tariff data or no data found.")
|
| 22 |
+
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|