AddisonSwan commited on
Commit
71f19a9
·
verified ·
1 Parent(s): 7255db9

Upload data_app.py

Browse files
Files changed (1) hide show
  1. data_app.py +64 -0
data_app.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from datetime import datetime
4
+ import os
5
+
6
+ st.set_page_config(page_title="🔧 Service Tech Tracker", layout="wide")
7
+ st.title("🔧 Service Tech Fuel & Job Tracker")
8
+
9
+ # Create folders
10
+ os.makedirs("data", exist_ok=True)
11
+ os.makedirs("jobs", exist_ok=True)
12
+
13
+ page = st.sidebar.radio("Go to", ["Gas & Mileage", "New Job", "All Data"])
14
+
15
+ if page == "Gas & Mileage":
16
+ st.subheader("⛽ Gas & Mileage Tracker")
17
+
18
+ col1, col2 = st.columns(2)
19
+ with col1:
20
+ country = st.selectbox("Country", ["USA", "Canada", "Other"])
21
+ region = st.text_input("State / Province / Region")
22
+
23
+ price = st.number_input("Gas Price", value=4.50, step=0.01)
24
+ miles = st.number_input("Miles Driven", value=0.0)
25
+ trip_type = st.radio("Type", ["Work", "Personal"])
26
+ notes = st.text_area("Notes (Job #, location, etc.)")
27
+
28
+ if st.button("Save Entry"):
29
+ new_row = pd.DataFrame([{
30
+ "Date": datetime.now().strftime("%Y-%m-%d"),
31
+ "Country": country,
32
+ "Region": region,
33
+ "Price": price,
34
+ "Miles": miles,
35
+ "Type": trip_type,
36
+ "Notes": notes
37
+ }])
38
+
39
+ try:
40
+ df = pd.read_csv("data/mileage.csv")
41
+ df = pd.concat([df, new_row], ignore_index=True)
42
+ except:
43
+ df = new_row
44
+ df.to_csv("data/mileage.csv", index=False)
45
+ st.success("✅ Saved!")
46
+
47
+ if os.path.exists("data/mileage.csv"):
48
+ st.dataframe(pd.read_csv("data/mileage.csv"))
49
+
50
+ elif page == "New Job":
51
+ st.subheader("📁 New Job")
52
+ job_id = st.text_input("Job ID")
53
+ client = st.text_input("Client")
54
+ desc = st.text_area("Description")
55
+ if st.button("Create Job"):
56
+ os.makedirs(f"jobs/{job_id}", exist_ok=True)
57
+ st.success(f"Job {job_id} created!")
58
+
59
+ elif page == "All Data":
60
+ st.subheader("All Records")
61
+ if os.path.exists("data/mileage.csv"):
62
+ st.dataframe(pd.read_csv("data/mileage.csv"))
63
+
64
+ st.caption("Service Tech Tracker • Hugging Face")