'charmap' codec can't decode byte 0x90

2020-06-30 05:51发布

I have a csv file with 100 tweets . I want to process each of these tweets. So, I write this code

import csv
with open('abctweets.csv',) as csvfile:
    reader = csv.DictReader(csvfile)
    count=0
    for row in reader:
        string = row['text']
        count=count+1
        print(count)

but after processing 578 tweets it throws the following error:-

return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 6784: character maps to <undefined>

According to the answers I modified code to

import csv with open('J_tsar_tweets.csv', encoding="utf8") as csvfile:
    reader = csv.DictReader(csvfile)
    count=0
    for row in reader:
        string = row['text']
        count=count+1
        print(count)

but then it does not even process 578 tweets and throws an error as: (result, consumed) =

self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 1193: invalid start byte

0条回答
登录 后发表回答