UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte, while reading csv file in pandas

后端 未结 2 775
离开以前
离开以前 2020-12-11 17:57

I know similar questions has been asked already I have seen all of them and tried but of little help. I am using OSX 10.11 El Capitan, python3.6., virtual environment, tried

2条回答
  •  不知归路
    2020-12-11 18:46

    It's still most likely gzipped data. gzip's magic number is 0x1f 0x8b, which is consistent with the UnicodeDecodeError you get.

    You could try decompressing the data on the fly:

    with open('destinations.csv', 'rb') as fd:
        gzip_fd = gzip.GzipFile(fileobj=fd)
        destinations = pd.read_csv(gzip_fd)
    

提交回复
热议问题