Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python CSV

Nick Larkins
seal-mask
.a{fill-rule:evenodd;}techdegree
Nick Larkins
Python Web Development Techdegree Student 1,390 Points

How do I fix the following error in Python CSV section UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81

How do I fix the following error in the 'Using CSV and json in python'.

I'm using the following script and using my own CSV file.

import csv import sys

with open('track_info.csv', newline='') as csvfile: track_reader = csv.reader(csvfile, delimiter = '|') rows = list(track_reader) for row in rows[::2]: print(', '.join(row))

I receive this error UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81 in position 10: invalid start byte

Thanks in advance

Kind regards

Nick

1 Answer

Try -->

with open('museum.csv', newline='', encoding='utf-8') as csvfile: