2

As a rookie, I just started to use the datareader library, in particular read_html function and came across the following error when trying to get a table from websites.

import pandas as pd
from pandas_datareader import data  

df_list=pd.read_html('https://www.mismarcadores.com/futbol/espana/laliga/clasificacion/') print(len(df_list))

And I get this syntax error with raise (line 346)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-44-c546df3e8ebd> in <module>()
----> 1 df_list=pd.read_html('https://www.mismarcadores.com/futbol/espana/laliga/clasificacion/')
      2 print(len(df_list))

~\Anaconda3\lib\site-packages\pandas\io\html.py in read_html(io, match, flavor, header, index_col, skiprows, attrs, parse_dates, tupleize_cols, thousands, encoding, decimal, converters, na_values, keep_default_na)
    904                   thousands=thousands, attrs=attrs, encoding=encoding,
    905                   decimal=decimal, converters=converters, na_values=na_values,
--> 906                   keep_default_na=keep_default_na)

~\Anaconda3\lib\site-packages\pandas\io\html.py in _parse(flavor, io, match, attrs, encoding, **kwargs)
    741             break
    742     else:
--> 743         raise_with_traceback(retained)
    744 
    745     ret = []

~\Anaconda3\lib\site-packages\pandas\compat\__init__.py in raise_with_traceback(exc, traceback)
    342         if traceback == Ellipsis:
    343             _, _, traceback = sys.exc_info()
--> 344         raise exc.with_traceback(traceback)
    345 else:
    346     # this version of raise is a syntax error in Python 3

ValueError: No tables found

Checking the HTML code there's actually a table tag on that url, and I do not understand why it does not pick it out...

Thanks a lot for your help.

  • Huh? That's a `ValueError`, not a syntax error. But more importantly, what's your question? – Aran-Fey Aug 24 '18 at 09:36
  • My goal is trying to pick out the table inside that url using read_html, and when I give it a try it shows that error in line 346 about the version of raise in Python 3 – Javier de la Iglesia Aug 24 '18 at 09:41
  • It's telling you that it didn't find any tables in that HTML. – Aran-Fey Aug 24 '18 at 09:42
  • I know, but 'Inspecting Element' in that website, you can actually observe a tag...
    – Javier de la Iglesia Aug 24 '18 at 09:44
  • So your question is *"Why can't `pd.read_html` find any tables on this website"*? Posting two lines of code and an exception traceback doesn't exactly communicate that clearly. Especially not with a question title like that. – Aran-Fey Aug 24 '18 at 09:46
  • The only code I added before was: _import pandas as pd_ AND _from pandas_datareader import data_ And what I do not understand is line 346 and why it says there are no tables when there's actually one. Sorry for the spelling, I am kind of new on the platform. – Javier de la Iglesia Aug 24 '18 at 10:05

0 Answers0