albhu commited on
Commit
0b8b44d
·
verified ·
1 Parent(s): e44e5cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import pandas as pd
3
  import openai
 
4
 
5
  # Streamlit App
6
  def main():
@@ -10,6 +11,9 @@ def main():
10
  api_key = st.text_input("Enter your OpenAI API key:")
11
 
12
  if api_key:
 
 
 
13
  # Allow user to upload Excel sheet
14
  uploaded_file = st.file_uploader("Upload Excel file", type=["xlsx", "xls"])
15
 
@@ -94,5 +98,23 @@ def analyze_excel(df):
94
 
95
  return due_dates, payment_dates, amounts
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  if __name__ == "__main__":
98
  main()
 
1
  import streamlit as st
2
  import pandas as pd
3
  import openai
4
+ import requests
5
 
6
  # Streamlit App
7
  def main():
 
11
  api_key = st.text_input("Enter your OpenAI API key:")
12
 
13
  if api_key:
14
+ # Download BOE rates
15
+ download_boe_rates()
16
+
17
  # Allow user to upload Excel sheet
18
  uploaded_file = st.file_uploader("Upload Excel file", type=["xlsx", "xls"])
19
 
 
98
 
99
  return due_dates, payment_dates, amounts
100
 
101
+ # Function to download Bank of England rates
102
+ def download_boe_rates():
103
+ try:
104
+ headers = {
105
+ 'accept-language': 'en-US,en;q=0.9',
106
+ 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'
107
+ }
108
+ url = 'https://www.bankofengland.co.uk/boeapps/database/Bank-Rate.asp'
109
+ response = requests.get(url, headers=headers)
110
+ if response.status_code == 200:
111
+ df = pd.read_html(response.text)[0]
112
+ df.to_csv('boe_rates.csv', index=False)
113
+ st.success("Bank of England rates downloaded successfully.")
114
+ else:
115
+ st.error("Failed to retrieve data from the Bank of England website.")
116
+ except requests.RequestException as e:
117
+ st.error(f"Failed to download rates: {e}")
118
+
119
  if __name__ == "__main__":
120
  main()