I am trying to read a csv-file from given URL using Python 3.
import pandas as pd
url = 'https://www.hkex.com.hk/eng/dwrc/search/dwFullList.csv' # error
url_2 = 'https://www.cboe.com/us/options/symboldir/equity_index_options/?download=csv
df = pd.read_csv(url) # error
df = pd.read_csv(url_2) # can download csv from url
When I run df = pd.read_csv(url)
the system return:
File "pandas\_libs\parsers.pyx", line 537, in pandas._libs.parsers.TextReader.__cinit__
File "pandas\_libs\parsers.pyx", line 740, in pandas._libs.parsers.TextReader._get_header
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
However, when I run df = pd.read_csv(url_2)
the system can return the dataframe.
How can I solve this problem? I am using Python 3.7.