Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import numpy as np
|
|
4 |
import os
|
5 |
|
6 |
# Configure the page to be mobile-friendly
|
7 |
-
st.set_page_config(layout="centered", page_title="Restaurant Data Viewer")
|
8 |
|
9 |
# URLs for the logos
|
10 |
MAIN_LOGO_URL = "https://islamictrusthk.org/assets/images/top-logo.png"
|
@@ -72,12 +72,23 @@ def display_tiles(df, cols):
|
|
72 |
|
73 |
# Function to detect the format and standardize the data
|
74 |
def standardize_data(df):
|
75 |
-
format_1_columns = {'
|
76 |
-
|
77 |
-
format_2_columns = {'Name', 'Address', 'Tel', 'Cuisine', 'Expiry DateDD/MM/YY', 'Location', 'Restaurant Type',
|
78 |
-
'Website', 'Directions'}
|
79 |
|
80 |
if format_1_columns.issubset(df.columns):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
df = df.rename(columns={
|
82 |
'Issued Date': 'Issued Date',
|
83 |
'Expiry Date': 'Expiry Date',
|
@@ -92,20 +103,7 @@ def standardize_data(df):
|
|
92 |
'Status': 'Status',
|
93 |
'Member Since': 'Member Since'
|
94 |
})
|
95 |
-
required_columns =
|
96 |
-
elif format_2_columns.issubset(df.columns):
|
97 |
-
df = df.rename(columns={
|
98 |
-
'Name': 'Company Name',
|
99 |
-
'Address': 'Address',
|
100 |
-
'Tel': 'Phone',
|
101 |
-
'Cuisine': 'Factory Type',
|
102 |
-
'Expiry DateDD/MM/YY': 'Expiry Date',
|
103 |
-
'Location': 'Region',
|
104 |
-
'Restaurant Type': 'Factory Type',
|
105 |
-
'Website': 'Website',
|
106 |
-
'Directions': 'Directions'
|
107 |
-
})
|
108 |
-
required_columns = list(format_1_columns) # Use the same required columns for consistency
|
109 |
else:
|
110 |
st.error("Unsupported file format")
|
111 |
return None, []
|
@@ -226,7 +224,7 @@ else:
|
|
226 |
company_name_filter = st.text_input("Company Name contains")
|
227 |
with col2:
|
228 |
# Filter by Location
|
229 |
-
location_filter = st.multiselect("
|
230 |
with col3:
|
231 |
# Filter by Restaurant Type
|
232 |
restaurant_type_filter = st.multiselect("Factory Type", df['Factory Type'].drop_duplicates())
|
|
|
4 |
import os
|
5 |
|
6 |
# Configure the page to be mobile-friendly
|
7 |
+
st.set_page_config(layout="centered", page_title="Hong Kong Halal Restaurant Data Viewer")
|
8 |
|
9 |
# URLs for the logos
|
10 |
MAIN_LOGO_URL = "https://islamictrusthk.org/assets/images/top-logo.png"
|
|
|
72 |
|
73 |
# Function to detect the format and standardize the data
|
74 |
def standardize_data(df):
|
75 |
+
format_1_columns = {'Name', 'Address', 'Tel', 'Cuisine', 'Expiry Date', 'Location', 'Restaurant Type', 'Website', 'Directions'}
|
76 |
+
format_2_columns = {'Issued Date', 'Expiry Date', 'Cert. No', 'Company Name', 'Address', 'Region', 'Factory Type', 'Contact', 'Phone', 'E-mail', 'Status', 'Member Since'}
|
|
|
|
|
77 |
|
78 |
if format_1_columns.issubset(df.columns):
|
79 |
+
df = df.rename(columns={
|
80 |
+
'Name': 'Company Name',
|
81 |
+
'Address': 'Address',
|
82 |
+
'Tel': 'Phone',
|
83 |
+
'Cuisine': 'Factory Type',
|
84 |
+
'Expiry Date': 'Expiry Date',
|
85 |
+
'Location': 'Region',
|
86 |
+
'Restaurant Type': 'Factory Type',
|
87 |
+
'Website': 'Website',
|
88 |
+
'Directions': 'Directions'
|
89 |
+
})
|
90 |
+
required_columns = ['Company Name', 'Address', 'Phone', 'Factory Type', 'Expiry Date', 'Region', 'Website', 'Directions']
|
91 |
+
elif format_2_columns.issubset(df.columns):
|
92 |
df = df.rename(columns={
|
93 |
'Issued Date': 'Issued Date',
|
94 |
'Expiry Date': 'Expiry Date',
|
|
|
103 |
'Status': 'Status',
|
104 |
'Member Since': 'Member Since'
|
105 |
})
|
106 |
+
required_columns = ['Issued Date', 'Expiry Date', 'Cert No', 'Company Name', 'Address', 'Region', 'Factory Type', 'Contact', 'Phone', 'E-mail', 'Status', 'Member Since']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
else:
|
108 |
st.error("Unsupported file format")
|
109 |
return None, []
|
|
|
224 |
company_name_filter = st.text_input("Company Name contains")
|
225 |
with col2:
|
226 |
# Filter by Location
|
227 |
+
location_filter = st.multiselect("Region", df['Region'].drop_duplicates())
|
228 |
with col3:
|
229 |
# Filter by Restaurant Type
|
230 |
restaurant_type_filter = st.multiselect("Factory Type", df['Factory Type'].drop_duplicates())
|