Engineer786 commited on
Commit
52c1a77
·
verified ·
1 Parent(s): 096c143

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -42
app.py DELETED
@@ -1,42 +0,0 @@
1
- import streamlit as st
2
- import pandas as pd
3
- from tariff_scraper import TARIFF_URLS, scrape_tariff_data_to_csv
4
-
5
- def main():
6
- st.title("Electricity Tariff Data Viewer")
7
- st.sidebar.header("Tariff Data Scraper")
8
-
9
- # Dropdown for selecting a company
10
- selected_company = st.sidebar.selectbox("Select a Company", options=list(TARIFF_URLS.keys()))
11
- st.sidebar.write("Selected Company:", selected_company)
12
-
13
- # Button to fetch and scrape data
14
- if st.sidebar.button("Fetch Tariff Data"):
15
- url = TARIFF_URLS[selected_company]
16
- st.sidebar.write(f"Fetching data from: {url}")
17
- with st.spinner("Scraping data..."):
18
- result = scrape_tariff_data_to_csv(url, output_file=f"{selected_company}_tariff_data.csv")
19
- if result.endswith(".csv"):
20
- st.sidebar.success(f"Data successfully saved to {result}")
21
- st.session_state["csv_file"] = result
22
- else:
23
- st.sidebar.error(f"Error: {result}")
24
-
25
- # Display the preview of the data if available
26
- if "csv_file" in st.session_state and st.session_state["csv_file"]:
27
- st.subheader("Preview of Tariff Data")
28
- try:
29
- csv_file = st.session_state["csv_file"]
30
- data = pd.read_csv(csv_file)
31
- st.write(data)
32
- st.download_button(
33
- label="Download Tariff Data as CSV",
34
- data=open(csv_file, "rb").read(),
35
- file_name=csv_file,
36
- mime="text/csv"
37
- )
38
- except Exception as e:
39
- st.error(f"An error occurred while loading the CSV file: {e}")
40
-
41
- if __name__ == "__main__":
42
- main()