awacke1 commited on
Commit
5145d36
Β·
1 Parent(s): ea5fc19

Create backupapp.py

Browse files
Files changed (1) hide show
  1. backupapp.py +71 -0
backupapp.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import csv
3
+ import base64
4
+
5
+ # Define the state populations and family sizes
6
+ state_data = {
7
+ 'California': {'population': 39538223, 'family_size': 3.3},
8
+ 'Texas': {'population': 29145505, 'family_size': 3.4},
9
+ 'Florida': {'population': 21538187, 'family_size': 3.0},
10
+ 'New York': {'population': 19849399, 'family_size': 3.1},
11
+ 'Minnesota': {'population': 5700671, 'family_size': 2.5},
12
+ 'Wisconsin': {'population': 5897473, 'family_size': 2.6},
13
+ }
14
+
15
+ # Define the state spending data
16
+ spending_data = {
17
+ 'California': {'education': 2500, 'healthcare': 3000, 'transportation': 1500},
18
+ 'Texas': {'education': 2000, 'healthcare': 2500, 'transportation': 1000},
19
+ 'Florida': {'education': 1500, 'healthcare': 2000, 'transportation': 750},
20
+ 'New York': {'education': 3000, 'healthcare': 3500, 'transportation': 2000},
21
+ 'Minnesota': {'education': 1000, 'healthcare': 1500, 'transportation': 500},
22
+ 'Wisconsin': {'education': 1250, 'healthcare': 1750, 'transportation': 750},
23
+ }
24
+
25
+ # Define the emoji icons
26
+ POPULATION_ICON = 'πŸ‘₯'
27
+ FAMILY_SIZE_ICON = 'πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦'
28
+ EDUCATION_ICON = '🏫'
29
+ HEALTHCARE_ICON = 'πŸ₯'
30
+ TRANSPORTATION_ICON = 'πŸš—'
31
+
32
+ def main():
33
+ st.title('State Comparison')
34
+
35
+ # Consolidate the state data and spending data into a list of dictionaries
36
+ state_list = []
37
+ for state, data in state_data.items():
38
+ state_dict = {
39
+ 'state': state,
40
+ 'population': data['population'],
41
+ 'family_size': data['family_size'],
42
+ 'education_spending': spending_data[state]['education'],
43
+ 'healthcare_spending': spending_data[state]['healthcare'],
44
+ 'transportation_spending': spending_data[state]['transportation']
45
+ }
46
+ state_list.append(state_dict)
47
+
48
+ # Save the data to a CSV file and provide a download link
49
+ with open('state_data.csv', mode='w', newline='') as file:
50
+ writer = csv.DictWriter(file, fieldnames=['state', 'population', 'family_size', 'education_spending', 'healthcare_spending', 'transportation_spending'])
51
+ writer.writeheader()
52
+ for state in state_list:
53
+ writer.writerow(state)
54
+ with open('state_data.csv', mode='rb') as file:
55
+ b64 = base64.b64encode(file.read()).decode('utf-8')
56
+ st.markdown(f'<a href="data:file/csv;base64,{b64}" download="state_data.csv">Download State Data CSV File</a>', unsafe_allow_html=True)
57
+
58
+ # Display state populations and family sizes
59
+ st.header('Population and Family Size')
60
+ for state, data in state_data.items():
61
+ st.subheader(f'{POPULATION_ICON} {state}')
62
+ st.write(f'Population: {data["population"]}')
63
+ st.write(f'Family Size: {data["family_size"]}')
64
+
65
+ # Display state spending data
66
+ st.header('State Spending')
67
+ for state, data in spending_data.items():
68
+ st.subheader(state)
69
+ st.write(f'{EDUCATION_ICON} Education: {data["education"]}')
70
+ st.write(f'{HEALTHCARE_ICON} Healthcare: {data["healthcare"]}')
71
+ st.write(f'{TRANSPORTATION_ICON} Transportation: {data["transportation"]}')