Skip to content

Commit 6510c57

Browse files
committed
fix: resolve data files relative to script directory
Budget Tracker and Productivity Pet were using bare filenames for their persistent data files, causing data to be written to the current working directory instead of the script's own directory. Running from a different path would silently create a new empty data file, losing all prior data.
1 parent 53afdbc commit 6510c57

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

utilities/Budget-Tracker/budget_tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from datetime import datetime
1111
from collections import defaultdict
1212

13-
DATA_FILE = "budget_data.csv"
13+
DATA_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "budget_data.csv")
1414
FIELDNAMES = ["date", "type", "category", "description", "amount"]
1515

1616
# ─────────────────────────────────────────────

utilities/Productivity-Pet/Productivity-Pet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
from datetime import datetime
88

9-
SAVE_FILE = "save.json"
9+
SAVE_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "save.json")
1010

1111
# =========================
1212
# LOAD SAVE DATA

0 commit comments

Comments
 (0)