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

None of these makes sense to me...

i keep getting this each time i run this code....

import csv

with open('credit.csv', newline='', encoding='utf-8') as csvfile:
    creditreader = csv.reader(csvfile, delimiter='|')
    rows = list(creditreader)
    for row in rows[1:3]:
        print(row)

treehouse:~/workspace$ python credits.py
Traceback (most recent call last):
File "credits.py", line 5, in <module>
rows = list(creditreader)
File "/usr/local/pyenv/versions/3.6.4/lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 808: invalid start byte

Provide data of your file here so that we can help you.

1 Answer

Steven Parker
Steven Parker
243,656 Points

The error seems to be saying that the contents of the file "credit.csv" are not correct.

To facilitate a complete analysis, make a snapshot of your workspace and post the link to it here.

Yes, the code is perfectly working on my own csv. The problem is in your file so we need the data you are using to help you.