-
Notifications
You must be signed in to change notification settings - Fork 2
/
META_DIRECTORY.py
145 lines (126 loc) Β· 6.07 KB
/
META_DIRECTORY.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 25 13:56:34 2022
@author: Xiaoyu Jin
"""
import streamlit as st
import pandas as pd
from pandas import DataFrame
#from gspread_pandas import Spread,Client
from google.oauth2 import service_account
import ssl
#Page title
st.set_page_config(
page_title="Building Data Genome Directory",
)
#Text contents
st.title("# Building Data Genome Directory")
st.subheader('π Welcome to Building Data Genome Directory!')
st.markdown(
"""
##### This is a comprehensive building dataset collection, where you can find the links for the datasets related with building energy research.\n
##### You are also more than welcome to contribute the link of your own datasets, by clicking the check button *'Add New Dataset'* on the left bar.\n
##### Please note that we are looking forward to datasets with the geospatial granularity levels of **_individual buildings_** or **_communities_**, instead of aggregated data of a city.\n
##### Please also note that we are maintaining the dataset links, rather than a database. Looking for places to upload your own dataset? Check the [Open Energy Platform](https://openenergy-platform.org/). You can update your link here after uploading your dataset.""")
st.subheader('Dataset Categories')
st.markdown(
"""
##### What kinds of datasets are you looking for?
""")
st.image("https://github.com/buds-lab/building-data-directory/raw/main/meta%20directory.png")
col1, col2, col3 = st.columns(3)
with col1:
st.subheader(
"""
π Check the category buttons on the left bar!
""")
with col2:
st.markdown("![Alt Text](https://github.com/buds-lab/building-data-directory/raw/main/browsing.gif)")
#%%
# Get the sheet as dataframe
def load_the_spreadsheet(spreadsheetname):
worksheet = sh.worksheet(spreadsheetname)
df = DataFrame(worksheet.get_all_records())
return df
#%%
#Link to google sheet
ssl._create_default_https_context = ssl._create_unverified_context
# Create a Google Authentication connection object
#scope = ["https://www.googleapis.com/auth/spreadsheets","https://www.googleapis.com/auth/drive"]
#credentials = service_account.Credentials.from_service_account_info(
#st.secrets["gcp_service_account"],
#st.secrets["gcp_service_account"],
#scopes=scope)
#client = Client(scope=scope,creds=credentials)
#spreadsheetname = "Dataset_Intro_List"
#spread = Spread(spreadsheetname,client = client)
#sh = client.open(spreadsheetname)
#dataset = load_the_spreadsheet('contributed from users')
from streamlit_gsheets import GSheetsConnection
# Create a connection object.
conn = st.connection("gsheets", type=GSheetsConnection)
dataset = conn.read(worksheet="contributed from users",usecols=[0,1,2,3])
dataset = dataset.dropna(thresh=2)
#%%
st.subheader(
"""
Datasets contributed by users
""")
st.markdown("""*Note: These datasets will be added to the directory after review*""")
for i in range(len(dataset)):
url = dataset['URL'][i]
dataset['URL'][i] = f'<a href="{url}">{url}</a>'
dataset.index = dataset.index + 1
users_html = dataset.iloc[:,:-1].to_html(escape=False)
st.write(users_html, unsafe_allow_html=True)
st.markdown(""" """)
st.markdown(""" """)
st.markdown(""" """)
st.subheader('To cite the Building Data Genome Directory:')
st.markdown(""" The Building Data Genome Directory β An open, comprehensive data sharing platform for building performance research. https://iopscience.iop.org/article/10.1088/1742-6596/2600/3/032003""")
st.markdown(""" """)
st.subheader('Other relevant publications:')
st.markdown(""" A review and reflection on open datasets of city-level building energy use and their applications. https://10.1016/j.enbuild.2023.112911""")
st.markdown(""" """)
st.markdown(""" """)
st.markdown("""*Any questions or ideas? Join our GitHub community at [building-data-directory Discussions](https://github.com/buds-lab/building-data-directory/discussions)*""")
st.markdown("""*Further questions? Contact usπ§: [email protected]*""")
st.markdown(""" """)
st.markdown("""*<p style="font-size: 12px;">Acknowledge for the support by the National Key Research and Development Program of China (2021YFE0107400), and the joint effort of the Annex 81 community.*</p>""",unsafe_allow_html=True)
st.image("https://github.com/buds-lab/building-data-directory/blob/main/Annex%2081%20logo.png?raw=true")
#%%
def update_the_spreadsheet(spreadsheetname,dataframe):
#col = ['Dataset Full Name','URL']
spread.df_to_sheet(dataframe,sheet = spreadsheetname,index= False)
st.sidebar.info('β
Submitted succussfully! Thank you for contributing.You can check your dataset on the right (contribution from users).')
#%%
add = st.sidebar.checkbox('Add New Dataset')
if add:
name_entry = st.sidebar.text_input('Dataset Name')
url_entry = st.sidebar.text_input('URL')
Type = ['1 𧱠Building Energy Ontologies',
'2 ποΈ Building Energy Models',
'3 π Building Energy and Water Data',
'4 π Electric Vehicle Data',
'5 π¦οΈ Weather Data',
'6 π Building_Information_Data',
'7 π Smart Grid Data',
'8 π Text Mining Based Research Data',
'9 β οΈ Fault Detection Diagnosis Data',
'10 π©βπ¦― Occupant Data',
'11 Other Categories']
select_type = st.sidebar.selectbox('Dataset Type',Type)
email = st.sidebar.text_input('Please leave your email (optional)')
confirm_input = 0
if (len(name_entry) != 0) & (len(url_entry) != 0):
confirm_input = st.sidebar.button('Confirm')
if confirm_input:
opt = {'Dataset Full Name': [name_entry],
'URL' : [url_entry],
'Type':[select_type],
'Email': [email]}
opt_df = DataFrame(opt)
df = load_the_spreadsheet('contributed from users')
new_df = pd.concat([df, opt_df], sort=False)
update_the_spreadsheet('contributed from users',new_df)
st.experimental_rerun()