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 trialJacob Khan
12,273 PointsThere 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])
Returns
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
KRIS NIKOLAISEN
54,971 PointsHave you seen this answer on stackoverflow?
I tested your code with a file named test.py and it ran.