This python script totals your PSN purchases in two ways; it provides a number of total purchases made, and the total amount of money spent on those purchases.
Sure you could! But if your account is as old as mine (15 years old as of 2024) it likely has hundreds, if not thousands of transactions. For old accounts, then, it's not feasible to manually count up each and every transaction - hence why I wrote this code! I've now shared it for anyone else curious for their total spending on PSN.
![Screenshot 2024-01-16 at 21 15 45](https://private-user-images.githubusercontent.com/30630493/297191040-b3545935-8aa0-421a-aaa9-6afe45ab0f0f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3MjI2MTgsIm5iZiI6MTcyNTcyMjMxOCwicGF0aCI6Ii8zMDYzMDQ5My8yOTcxOTEwNDAtYjM1NDU5MzUtOGFhMC00MjFhLWFhYTktNmFmZTQ1YWIwZjBmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA3VDE1MTgzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI0M2M3ZDNkMTY4NGEyMjhmMjRmZWFiOWFjNjJkZGJhZDRiZmZhOTUxMzIxZWVlYTVmY2Q1Mjk4MDJhYmVkMjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.o6vVp_Vn95ACI9Z-dCEoz7-vIGnRthonaDxGPcwLYvg)
Firstly, download the playstation_purchases.py file.
Make sure Python is installed on your system. You can download it from python.org.
1. Open Terminal:
- Press
Cmd + Space
to open Spotlight Search. - Type "Terminal" and press
Enter
to open the Terminal.
2. Navigate to the Script's Directory:
- Use the
cd
command to change the directory to where your Python script is located. For example:cd path/to/your/script
3. Run the Script:
- Once you're in the script's directory, run the script using the
python
command:python playstation_purchases.py
1. Open Command Prompt:
- Press
Win + R
to open the Run dialog. - Type "cmd" and press
Enter
to open the Command Prompt.
2. Navigate to the Script's Directory:
- Use the
cd
command to change the directory to where your Python script is located. For example:cd path\to\your\script
3. Run the Script:
- Once you're in the script's directory, run the script using the
python
command:playstation_purchases.py
Is python not recognised by your command line? Here's how to fix the issue:
-
Find Python Executable Path:
- Open Terminal.
- Type the following command to find the Python executable path:
which python
This will display the path to the Python executable.
-
Add Python to PATH:
-
Open or create your shell configuration file. For example, for the default Bash shell, you can use:
nano ~/.bash_profile
-
Add the following line at the end of the file:
export PATH="/path/to/python/bin:$PATH"
Replace "/path/to/python/bin" with the actual path you obtained from the first step.
-
Save the file and exit. If you used
nano
, pressCtrl + X
, thenY
to confirm changes, andEnter
to exit. -
Restart Terminal or run the following command to apply the changes:
source ~/.bash_profile
-
-
Verify:
- Type
python
again in the terminal. It should now recognize the command.
- Type
-
Find Python Executable Path:
- Open Command Prompt.
- Type the following command to find the Python executable path:
where python
This will display the path to the Python executable.
-
Add Python to PATH:
-
Right-click on "This PC" or "Computer" on your desktop or in File Explorer.
-
Select "Properties" > "Advanced system settings" > "Environment Variables."
-
In the "System variables" section, find and select the "Path" variable, then click "Edit."
-
Click "New" and add the path to the Python executable (without the actual executable filename) that you obtained from the first step.
-
Click "OK" to close each dialog.
-
Restart Command Prompt.
-
-
Verify:
- Type
python
again in the Command Prompt. It should now recognize the command.
- Type
After following these steps, your system should recognize the python
command in the terminal or Command Prompt.
- Migrating to a user-friendly web-page using Github Pages, removing the need for a downloaded script and terminal/command prompt usage.
- Insight-gathering from data, e.g.:
- The year/month/day most purchases were made
- The most expensive year/month/day
- Seasonal trends (e.g. favourite season for purchases)
- Monthly trends (e.g. what day of the month are most purchases made)
- Average purchase amount
- Most expensive purchase
- Cheapest non-0 purchase
- Longest transaction free period
- Longest purchase streak (days)
- etc...