-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (40 loc) · 1.5 KB
/
main.py
File metadata and controls
51 lines (40 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'''
main.py - Spotify Global Trends Analysis
This script handles the automated data cleaning and launches the dashboard.
'''
import os
import sys
import subprocess
from src.cleaner import SpotifyCleaner
def prepare_data():
"""
Data Preparation: Loads the raw dataset, applies cleaning logic, and saves the output.
"""
print("Initializing data preparation pipeline.")
# Define paths for input and output files
raw_csv = os.path.join("data", "track_data_final.csv")
cleaned_csv = os.path.join("data", "cleaned_data.csv")
# Run the cleaning process using SpotifyCleaner class
cleaner = SpotifyCleaner(input_path=raw_csv)
print(f"Loading raw data from: {raw_csv}")
cleaner.load_data()
print("Applying cleaning and preprocessing steps.")
cleaner.clean()
print(f"Saving processed data to: {cleaned_csv}")
cleaner.save_data(output_path=cleaned_csv)
print("Data preparation completed successfully.\n")
def run_dashboard():
"""
Launching Dashboard: Starts the Streamlit application as a subprocess.
"""
print("Starting the Streamlit dashboard app.")
try:
# Run streamlit run app.py using the current python executable
subprocess.run([sys.executable, "-m", "streamlit", "run", "app.py"])
except Exception as e:
print(f"\nFailed to start the dashboard: {e}")
if __name__ == "__main__":
# First refresh the cleaned data
prepare_data()
# Then open the web interface
run_dashboard()