I am trying to load with Pandas a csv file directly from a url. The csv file is compressed as a .gz file:
#Importing libraries
import pandas as pd
import requests
import io
#defining the url
url = "https://data.brasil.io/dataset/covid19/caso_full.csv.gz"
An here is the error:
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-28-58ebbb6aba80> in <module>
7 url = "https://data.brasil.io/dataset/covid19/caso_full.csv.gz"
8 s=requests.get(url).content
----> 9 df=pd.read_csv(io.StringIO(s.decode('utf-8')), sep=',', compression='gzip', index_col=0, quotechar='"')
10
11 #df=pd.read_csv("caso_full.csv.gz")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
s=requests.get(url).content
df=pd.read_csv(io.StringIO(s.decode('utf-8')), sep=',', compression='gzip', index_col=0, quotechar='"')
If I download the file directly there is no error when I open it:
#Importing libraries
import pandas as pd
df=pd.read_csv("caso_full.csv.gz")
Any tips on why this is happening?
Thank you!