Spaces:
Sleeping
Sleeping
Commit
·
1e52f6c
1
Parent(s):
0c99c1c
Upload main.py
Browse files
main.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import base64
|
4 |
+
import datetime
|
5 |
+
def main():
|
6 |
+
st.title("Friends in Flats Wohnungs Setup Assistant")
|
7 |
+
st.write("""Bitte Schicken sie uns das excel file nach ihrer überprufung an [email protected] zum verarbeiten.
|
8 |
+
Bei Fragen uns bitte Kontaktieren auf : +43720882394""")
|
9 |
+
address = st.text_input("Address")
|
10 |
+
num_rooms = st.number_input("Number of Rooms", min_value=1, step=1)
|
11 |
+
room_details = []
|
12 |
+
for i in range(num_rooms):
|
13 |
+
room_type = st.text_input(f"Zimmer {i+1} Typ")
|
14 |
+
num_amenities = st.number_input(f"Nummer von Zimmern in der Wohnung: {i+1}", min_value=0, step=1)
|
15 |
+
amenities = []
|
16 |
+
for j in range(num_amenities):
|
17 |
+
amenity_serial = st.text_input(f"Austattung {j+1} Serien Nummer")
|
18 |
+
amenity_type = st.text_input(f"Austattung {j+1} Typ")
|
19 |
+
amenity_details = st.text_input(f"Austattung {j+1} Details")
|
20 |
+
amenity_image = st.file_uploader(f"Austattung {j+1} Foto", type=["png", "jpg", "jpeg"], accept_multiple_files=False, key=f"amenity_{j+1}_image")
|
21 |
+
if amenity_image is not None:
|
22 |
+
encoded_image = base64.b64encode(amenity_image.read()).decode("utf-8")
|
23 |
+
else:
|
24 |
+
encoded_image = ""
|
25 |
+
amenities.append({
|
26 |
+
"Serial Number": amenity_serial,
|
27 |
+
"Type": amenity_type,
|
28 |
+
"Image": encoded_image,
|
29 |
+
"Details":amenity_details
|
30 |
+
})
|
31 |
+
room_details.append({
|
32 |
+
"Room Type": room_type,
|
33 |
+
"Amenities": amenities
|
34 |
+
})
|
35 |
+
if st.button("Save as Excel"):
|
36 |
+
file_path = st.file_uploader("Wo wollen sie die excel datei Speichern", type=["xlsx"], accept_multiple_files=False, key="excel_file_path")
|
37 |
+
if file_path is not None:
|
38 |
+
save_as_excel(file_path, address, room_details)
|
39 |
+
def save_as_excel(file_path, address, room_details):
|
40 |
+
current_time = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
41 |
+
data = {
|
42 |
+
"Address": [address],
|
43 |
+
"Room Type": [],
|
44 |
+
"Amenity Serial Number": [],
|
45 |
+
"Amenity Type": [],
|
46 |
+
"Amenity Image": [],
|
47 |
+
"Amenity Details":[]
|
48 |
+
}
|
49 |
+
for room in room_details:
|
50 |
+
room_type = room["Room Type"]
|
51 |
+
for amenity in room["Amenities"]:
|
52 |
+
data["Room Type"].append(room_type)
|
53 |
+
data["Amenity Serial Number"].append(amenity["Serial Number"])
|
54 |
+
data["Amenity Type"].append(amenity["Type"])
|
55 |
+
data["Amenity Image"].append(amenity["Image"])
|
56 |
+
data["Amenity Details"].append(amenity["Details"])
|
57 |
+
df = pd.DataFrame(data)
|
58 |
+
df.to_excel(file_path, index=False)
|
59 |
+
if __name__ == "__main__":
|
60 |
+
main()
|