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 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.