Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Data Science Basics Describing Data Loading Raw Data

There is an import error in my code

import csv

def open_with_csv(filename, d='\t'): data = [] with open(filename, encoding='utf-8') as tsvin: tie_reader = csv.reader(tsvin, delimiter=d) for line in tie_reader: data.append(line) return data

data_from_csv = open_with_csv('data.csv') print(data_from_csv[0])


Traceback (most recent call last):
File "csv.py", line 1, in <module>
import csv
File "/home/treehouse/workspace/csv.py", line 11, in <module>
data_from_csv = open_with_csv('data.csv')
File "/home/treehouse/workspace/csv.py", line 6, in open_with_csv
tie_reader = csv.reader(tsvin, delimiter=d)
AttributeError: module 'csv' has no attribute 'reader'

1 Answer

Have you seen this answer on stackoverflow?

I tested your code with a file named test.py and it ran.