Jump to content
×
×
  • Create New...

Total Steam Expense Script


Recommended Posts

I have written and tested a small python script that reads a text file of data copied directly from Steam transaction history to calculate the total spent on Steam games. Spoiler, it's a lot more than I thought it was!

Program Code

print("The total cost of steam purchases.")

transactions = 0
transaction_counter = 0
transaction_history = open("steam-transaction-history.txt")

for next_line in transaction_history:
		
	if (next_line[:3] in ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") and ("\n" in next_line[:14])):
		print("\nFound valid date: " + str(next_line[:12]))
		title = transaction_history.readline()
		while not ("Purchase\n" in title):
			print(title[:-1])
			title = transaction_history.readline()
		next_line = title
		
	if "Purchase\n" in next_line:
		if transaction_history.readline().split(" ")[0] in ("Visa", "PayPal\n", "American", "MasterCard", "Discover", "JCB"):
			purchase = transaction_history.readline()
			transaction_counter += 1
			print(str(transaction_counter) + ": " + str(purchase[:6]))
			transactions += float(purchase[1:6])

print("\nYour total expenditure on Steam is: $" + str(round(transactions, 2)))

Instructions

  1. Download attached .py script Copy code above to a file with a .py extension in a directory (desktop is fine) ie steam-total-cost.py
  2. Log in to Steam (you can do this in browser at steam login webpage if you don't have steam installed)
    1. Kudos to you for uninstalling Steam if so.
  3. Click {username} in top left -> Account Details -> View Purchase History
  4. Scroll down and click Load More
  5. ctrl + a -> ctrl + c
  6. Create a txt file in the same directory as the python program, naming it steam-transaction-history.txt
  7. Open the text file -> ctrl + v -> ctrl + s
    1. don't worry about any excess text like Valve info at header and footer of file
    2. don't reformat
  8. Open your system terminal -> navigate to the chosen directory (ie desktop)
    1. If you don't know how to use your system terminal, then search how to change directory, list files in current directory, etc for your OS/terminal.
  9. type
    python3 steam-total-cost.py
    and press enter
    1. you may need to install python; google python cli installation for {your OS} and follow instructions
  10. Share the total below. Behold in humiliation how much you and others have spent. 😦

Truncated Output

Quote

The total cost of steam purchases.

...{other purchases redacted for brevity}...

Found valid date: Dec 29, 2012
Dawn of War Franchise Pack
96: $19.99

Found valid date: Nov 13, 2012
A Game of Dwarves
97: $9.99    

Your total expenditure on Steam is: $1800.29

I had no idea I was averaging $17 / month on the steam store for almost a decade, and that doesn't include purchases on other platforms! 🤯

My code is far from perfect and my Python is very rusty. I'm much more familiar with Java. Let me know if you get strange output, unlike what I've shared above.

Edited by ArcaneCoder
grammar
  • Like 1
Link to post
Share on other sites
  • ArcaneCoder changed the title to Total Steam Expense Script

I don't think I really want to know how much money I spent on Steam and all those other platforms.

I would be interested to know the total number of hours I wasted in said games, though, and also to reconstruct the history of my descent after I downloaded steam, lo these many long years ago.

  • Like 1
Link to post
Share on other sites
22 hours ago, Zeno said:

I don't think I really want to know how much money I spent on Steam and all those other platforms.

I would be interested to know the total number of hours I wasted in said games, though, and also to reconstruct the history of my descent after I downloaded steam, lo these many long years ago.

Sure.

Script Code

print("The total playtime of steam games.\n")

total_playtime = 0
game_counter = 0
title_buffer = ""
playtime_history = open("steam-playtime-history.txt")

for next_line in playtime_history:
	if "hrs on record" in next_line:
		game_counter += 1
		playtime = float(next_line.split(" ")[0])
		print( str(game_counter) + ": " + str(title_buffer[:-1]) + " " + str(playtime) + "hrs\n" )
		total_playtime += playtime
		print( "Running total: " + str(round(total_playtime,1)) + "\n" )
	title_buffer = next_line

print( "A total of " + str(round(total_playtime,1)) + " hours across " + str(game_counter) + " games on steam." )
print( "\nExamples\n" )
print( "\t* Equivalent to " + str(round(total_playtime / 2000.00, 2) ) + " years of full-time work.\n" )
print( "\t* Equivalent to earning $" + str(round(total_playtime * 7.25, 2)) + " at a wage of $7.25.\n" )
print( "\t* Equivalent to studying for " + str(round(total_playtime / 4800.00, 2)) + " bachelors degrees.\n" )

Like OP, but file is named steam-playtime-history.txt and copy the data from: View profile -> Games.

Unfortunately, unless Valve stores playtime activity with timestamps, it's not probable the playtime can be broken down to the month or year. But, knowing when a game was bought, it's possible to relate the playtime to date of purchase.

Example Output

Quote

The total playtime of steam games.

1: Sid Meier's Civilization V 973.0hrs

Running total: 973.0

...{other games}...

152: Stronghold Crusader HD 0.1hrs

Running total: 11389.9

A total of 11389.9 hours across 152 games on steam.

Examples

    * Equivalent to 5.69 years of full-time work.

    * Equivalent to earning $82576.77 at a wage of $7.25.

    * Equivalent to studying for 2.37 bachelors degrees.

And to think, this excludes time I wasted on mmos and non-steam games. My first steam purchase was in late 2012.

Maybe next, I can combine logic from both scripts and generate a graph relating playtime to date of purchase to "reconstruct the history of my descent after I downloaded steam."

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.