Parse_data_from_file()

hi,

I’m trying to complete C3W3_Assignment. I’m working on the parse_data_from_file().

def parse_data_from_file(filename):
    # [snippet deleted by mentor]
    pass

Here’s the error:

UnicodeDecodeError                        Traceback (most recent call last)
Cell In[54], line 2
      1 # Test your function
----> 2 sentences, labels = parse_data_from_file(SENTIMENT_CSV)
---> 14     for row in reader:

File /usr/lib/python3.8/codecs.py:322, in BufferedIncrementalDecoder.decode(self, input, final)
    319 def decode(self, input, final=False):
    320     # decode input (taking the buffer into account)
    321     data = self.buffer + input
--> 322     (result, consumed) = self._buffer_decode(data, self.errors, final)
    323     # keep undecoded input until the next call
    324     self.buffer = data[consumed:]

UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 7970-7971: invalid continuation byte

could it be something is wrong with “training_cleaned.csv”? though it seems to be fine; i can open it in LibreOffice.

[trace adjusted by mentor]

thanks,
Ed

Your code works fine and data/training_cleaned.csv has no parsing issues on coursera lab environment. Please refresh your workspace and try again.