rasbt / datacollect

A collection of tools to collect and download various data.
GNU General Public License v3.0
209 stars 97 forks source link

Encoding issue when trying to run soccer collect py file #1

Closed ladams81 closed 9 years ago

ladams81 commented 9 years ago

When i try and run collect_fantasysoccer it threw the following error below

SyntaxError: Non-ASCII character '\xc2' in file collect_fantasysoccer.py on line 415, but no encoding
declared; see http://www.python.org/peps/pep-0263.html for details

I then added the following line to the py file

coding=UTF-8

Tried to run again, this time it got further but resulted in the following error below

Getting general statistics from https://www.dreamteamfc.com/statistics/players/ALL/ ... Getting team standings from http://www.espnfc.com/barclays-premier-league/23/table ... collect_fantasysoccer.py:197: UnicodeWarning: Unicode unequal comparison failed to convert both arguments to Unicode - interpreting them as being unequal res = [i.text for i in td.next_siblings if isinstance(i, bs4.element.Tag) and i.text!='\xa0'] Traceback (most recent call last): File "collect_fantasysoccer.py", line 528, in epl_data.get_all() File "collect_fantasysoccer.py", line 41, in get_all self.get_team_standings() File "collect_fantasysoccer.py", line 199, in get_team_standings values = [int(i) for i in res[1:]] ValueError: invalid literal for int() with base 10: ''

Could you advise me as to how to get around this?

Appreciated

rasbt commented 9 years ago

I am sorry about this issue. One quick question: Are you using Python 2.7 or 3.4? I only tested it with 3.4 - since I've always had issues with unicode in Python 2.7 I typically only use Python 3.4 for such things.

ladams81 commented 9 years ago

Hi there.

Thanks for the swift response. Im using Python 2.7. Its probably the default one installed with this mac.

Okay thanks I'll try python 3.4 and let you know.

rasbt commented 9 years ago

You are welcome, and thanks for bringing this up, I will add a note about Python 3 usage to make life easier for other users :). Yes, Python 2.7 is the default for Mac OSX. In general, I wouldn't recommend using the default (system's) python version. If you are about to install a "new" Python version, have a look at Anaconda. It's a free Python distribution that makes the usage of virtual environments and installation of most major libraries (and updating them) really easy and convenient (especially the compiled stuff like NumPy, SciPy etc.). Most people that I know are using it :) https://store.continuum.io/cshop/anaconda/

ladams81 commented 9 years ago

Hi there.

Thanks for the info. Upgrading to Python 3 did rectify the issue for me.

Cheers

rasbt commented 9 years ago

Nice, I am glad to hear! Especially when it comes to text (and "exotic" characters), Python 3 makes life a lot easier ;)