├── ADD_DATA_TUTORIAL
├── Main.py
├── __pycache__
│ └── template.cpython-311.pyc
├── data.xlsx
└── template.py
├── Main.py
├── README.md
├── __pycache__
└── template.cpython-311.pyc
├── config.toml
├── data.xlsx
├── requirements.txt
└── template.py
/ADD_DATA_TUTORIAL/Main.py:
--------------------------------------------------------------------------------
1 | import streamlit as st
2 | import pandas as pd
3 | import random
4 | from datetime import date
5 | import datetime
6 | from template import *
7 |
8 | st.set_page_config(page_title='Dashboard', page_icon=None, layout='wide', initial_sidebar_state='auto')
9 | st.markdown("##")
10 |
11 | UI()
12 | st.markdown("##")
13 |
14 | todayDate = datetime.date.today()
15 | #currentYear = date.today().year
16 | rondomNumber=(random.randint(0,10000))
17 |
18 | #load excel file
19 | df=pd.read_excel('data.xlsx', sheet_name='Sheet1')
20 |
21 |
22 |
23 | #top analytics
24 | def Analytics():
25 | purchasing_price_ = float(df['purchasing_price'].sum())
26 | selling_price_ = float(df['selling_price'].sum())
27 | profit = float(df['expected_profit'].sum())
28 |
29 | #3. columns
30 | total1,total2,total3= st.columns(3,gap='small')
31 | with total1:
32 |
33 | st.info('Purchasing Price', icon="🔍")
34 | st.metric(label = 'TZS', value= f"{purchasing_price_:,.0f}")
35 |
36 | with total2:
37 | st.info('Selling Price', icon="🔍")
38 | st.metric(label='TZS', value=f"{selling_price_:,.0f}")
39 |
40 | with total3:
41 | st.info('Expected Profit', icon="🔍")
42 | st.metric(label= 'TZS',value=f"{profit:,.0f}")
43 |
44 | Analytics()
45 | st.markdown("""---""")
46 |
47 |
48 | #form
49 | st.sidebar.header("Add New Product")
50 | options_form=st.sidebar.form("Option Form")
51 | product_name=options_form.text_input("name")
52 | product_type=options_form.selectbox("Type",{"New","Used"})
53 | category=options_form.selectbox("Type",{"Soap","Perfume","Lotion","Other"})
54 | serial_number=options_form.text_input("Product ID",value=rondomNumber,disabled=True)
55 | date_added=options_form.text_input("Registered",value=todayDate,disabled=True)
56 | purchasing_price=options_form.number_input("Purchasing price")
57 | selling_price=options_form.number_input("Selling Price")
58 | add_data=options_form.form_submit_button(label="Add new record")
59 |
60 | #when button is clicked
61 | if add_data:
62 | if product_name !="":
63 | df = pd.concat([df, pd.DataFrame.from_records([{
64 | 'product_name': product_name,
65 | 'type':product_type,
66 | 'category':category,
67 | 'serialNo':serial_number,
68 | 'date_added':date_added,
69 | 'purchasing_price':float(purchasing_price),
70 | 'selling_price':float(selling_price),
71 | 'expected_profit':selling_price-purchasing_price
72 | }])])
73 | try:
74 | df.to_excel("data.xlsx",index=False)
75 | except:
76 | st.warning("Unable to write, Please close your dataset !!")
77 | else:
78 | st.sidebar.error("product name required")
79 |
80 | with st.expander("Records"):
81 | shwdata = st.multiselect('Filter :', df.columns, default=['product_name','type','category','serialNo','date_added','purchasing_price','selling_price','expected_profit'])
82 | st.dataframe(df[shwdata],use_container_width=True)
83 |
84 | with st.expander("Cross Tab"):
85 | tab=pd.crosstab([df.category],df.type, margins=True)
86 | st.dataframe(tab)
--------------------------------------------------------------------------------
/ADD_DATA_TUTORIAL/__pycache__/template.cpython-311.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shamiraty/add-data-to-excel-streamlit/a08a52d3f3c58e637df1c811a25e073b47aa31ca/ADD_DATA_TUTORIAL/__pycache__/template.cpython-311.pyc
--------------------------------------------------------------------------------
/ADD_DATA_TUTORIAL/data.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shamiraty/add-data-to-excel-streamlit/a08a52d3f3c58e637df1c811a25e073b47aa31ca/ADD_DATA_TUTORIAL/data.xlsx
--------------------------------------------------------------------------------
/ADD_DATA_TUTORIAL/template.py:
--------------------------------------------------------------------------------
1 | import streamlit as st
2 |
3 | def UI():
4 | st.markdown("""
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
⚛ Add Data to Excel File | Data Visualization
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
30 | """, unsafe_allow_html=True)
--------------------------------------------------------------------------------
/Main.py:
--------------------------------------------------------------------------------
1 | import streamlit as st
2 | import pandas as pd
3 | import random
4 | from datetime import date
5 | import datetime
6 | from template import *
7 |
8 | st.set_page_config(page_title='Dashboard', page_icon=None, layout='wide', initial_sidebar_state='auto')
9 | st.markdown("##")
10 |
11 | UI()
12 | st.markdown("##")
13 |
14 | todayDate = datetime.date.today()
15 | #currentYear = date.today().year
16 | rondomNumber=(random.randint(0,10000))
17 |
18 | #load excel file
19 | df=pd.read_excel('data.xlsx', sheet_name='Sheet1')
20 |
21 |
22 |
23 | #top analytics
24 | def Analytics():
25 | purchasing_price_ = float(df['purchasing_price'].sum())
26 | selling_price_ = float(df['selling_price'].sum())
27 | profit = float(df['expected_profit'].sum())
28 |
29 | #3. columns
30 | total1,total2,total3= st.columns(3,gap='small')
31 | with total1:
32 |
33 | st.info('Purchasing Price', icon="🔍")
34 | st.metric(label = 'TZS', value= f"{purchasing_price_:,.0f}")
35 |
36 | with total2:
37 | st.info('Selling Price', icon="🔍")
38 | st.metric(label='TZS', value=f"{selling_price_:,.0f}")
39 |
40 | with total3:
41 | st.info('Expected Profit', icon="🔍")
42 | st.metric(label= 'TZS',value=f"{profit:,.0f}")
43 |
44 | Analytics()
45 | st.markdown("""---""")
46 |
47 |
48 | #form
49 | st.sidebar.header("Add New Product")
50 | options_form=st.sidebar.form("Option Form")
51 | product_name=options_form.text_input("name")
52 | product_type=options_form.selectbox("Type",{"New","Used"})
53 | category=options_form.selectbox("Type",{"Soap","Perfume","Lotion","Other"})
54 | serial_number=options_form.text_input("Product ID",value=rondomNumber,disabled=True)
55 | date_added=options_form.text_input("Registered",value=todayDate,disabled=True)
56 | purchasing_price=options_form.number_input("Purchasing price")
57 | selling_price=options_form.number_input("Selling Price")
58 | add_data=options_form.form_submit_button(label="Add new record")
59 |
60 | #when button is clicked
61 | if add_data:
62 | if product_name !="":
63 | df = pd.concat([df, pd.DataFrame.from_records([{
64 | 'product_name': product_name,
65 | 'type':product_type,
66 | 'category':category,
67 | 'serialNo':serial_number,
68 | 'date_added':date_added,
69 | 'purchasing_price':float(purchasing_price),
70 | 'selling_price':float(selling_price),
71 | 'expected_profit':selling_price-purchasing_price
72 | }])])
73 | try:
74 | df.to_excel("data.xlsx",index=False)
75 | except:
76 | st.warning("Unable to write, Please close your dataset !!")
77 | else:
78 | st.sidebar.error("product name required")
79 |
80 | with st.expander("Records"):
81 | shwdata = st.multiselect('Filter :', df.columns, default=['product_name','type','category','serialNo','date_added','purchasing_price','selling_price','expected_profit'])
82 | st.dataframe(df[shwdata],use_container_width=True)
83 |
84 | with st.expander("Cross Tab"):
85 | tab=pd.crosstab([df.category],df.type, margins=True)
86 | st.dataframe(tab)
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # add-data-to-excel-streamlit
2 | 
3 | 
4 | 
5 | 
6 | 
7 | 
8 | 
9 |
--------------------------------------------------------------------------------
/__pycache__/template.cpython-311.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shamiraty/add-data-to-excel-streamlit/a08a52d3f3c58e637df1c811a25e073b47aa31ca/__pycache__/template.cpython-311.pyc
--------------------------------------------------------------------------------
/config.toml:
--------------------------------------------------------------------------------
1 | [theme]
2 | primaryColor="#019aa2"
3 | backgroundColor="#010b39"
4 | secondaryBackgroundColor="#003852"
5 | textColor="#ffffff"
6 |
--------------------------------------------------------------------------------
/data.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shamiraty/add-data-to-excel-streamlit/a08a52d3f3c58e637df1c811a25e073b47aa31ca/data.xlsx
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | Markdown==3.4.3
2 | markdown-it-py==2.2.0
3 | MarkupSafe==2.1.2
4 | matplotlib==3.7.1
5 | numerize==0.12
6 | numpy==1.23.5
7 | oauthlib==3.2.2
8 | openpyxl==3.1.2
9 | opt-einsum==3.3.0
10 | packaging==23.1
11 | pandas==2.0.1
12 | pandas-profiling==3.2.0
13 | streamlit==1.22.0
14 | streamlit-apexjs==0.0.3
15 | streamlit-card==0.0.4
16 | streamlit-elements==0.1.0
17 | streamlit-option-menu==0.3.2
18 | streamlit-pandas-profiling==0.1.3
19 | plotly==5.14.1
20 | plotly-express==0.4.1
21 | scikit-learn==1.2.2
22 | seaborn==0.12.2
23 | pandas-profiling==3.2.0
24 |
--------------------------------------------------------------------------------
/template.py:
--------------------------------------------------------------------------------
1 | import streamlit as st
2 |
3 | def UI():
4 | st.markdown("""
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
⚛ Add Data to Excel File | Data Visualization
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
30 | """, unsafe_allow_html=True)
--------------------------------------------------------------------------------