My first Medium Article - Visualize your Steam Purchase History with Python

I would like to present my very first article on Medium:

Visualize your Steam Purchase History with Python | by Alexander Lacson | May, 2021 | Medium

I would appreciate feedback. I would also appreciate if someone would try to follow along with the article and report back if they found it easy or difficult.

3 Likes

Hi there,

I tried to follow along to your article but am getting stuck at this point which seems to be when its gathering the data via beautiful soup and then translating it to float so I could not complete it yet. Just wondering if you have any idea how I might fix this

Traceback (most recent call last):
File “steam.py”, line 15, in
wht_total = [float(each.get_text().strip()[1:].replace(’,’, ‘’)) for each in wht_total[1:]]
File “steam.py”, line 15, in
wht_total = [float(each.get_text().strip()[1:].replace(’,’, ‘’)) for each in wht_total[1:]]
ValueError: could not convert string to float: ‘$ 14.47’

seems to be related to this line
wht_total = [float(each.get_text().strip()[1:].replace(’,’, ‘’)) for each in wht_total[1:]]

Cool article idea though :slight_smile: Really hope I can get this working.

I actually figured this out in the end, hopefully this helps you tweak the article :slight_smile:

The problem seemed to be related to the fact that my exported HTML had $A (AU dollar) next to the amount in the file, thus it was not a number but a string. Once I did a find replace and removed all those it started to work. May need to account for this in the parsing logic.

Second problem I ran into was display was not defined, that was fixed with the following line
from IPython.display import display

Once I had done these things all the code was working :slight_smile:

1 Like

Thank you!
Regarding the error of ‘could not convert to float’, I will use Regular Expressions to string match only the numbers in the string, so that there will be no error when trying to convert to float.
Thanks for helping me improve this article.

As for the display issue, I decided to remove display so that the code can be run even on an IDE that is not Jupyter.

Just saw this in the newsletter, what a great tool! :+1:

1 Like