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 Data Science Basics Describing Data Loading Data

toanh tran
toanh tran
9,083 Points

Data Science Basic. I can't figure out what is wrong with my code. Please review. I get the Bummer! Try again.

Challenge Task 2 of 2

Now that you have the csv module imported, write a function named open_with_csv that takes one argument, a string with a file name. Within open_with_csv, assign an empty list to a variable named data. Return the value of data.

loadData.py
import csv  

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

3 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Toanh;

This challenge is rather explicit in what it wants. You have some extra code in there that it is not expecting to see which alters the data.

Post back if you are still stuck.

Ken

import csv  

def open_with_csv(filename, d='\t'):
    data = []

    return data
toanh tran
toanh tran
9,083 Points

Thanks! I figured it out. I was overthinking the solution.