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 trialDavid Wright
4,437 Pointsdon't know how to proceed
Any help would be great! Thank you.
from openWithCsv import *
data_from_csv = open_with_csv('data.csv')
def filter_col_by_string(the_data, field, filter_condition):
filtered_rows = []
#find index of field in first row
col = int(the_data[0].index(field))
filtered_rows.append(the_data[0])
for row in the_data[1:]:
if row[col] == filter_condition:
filtered_rows.append([str(x).encode('utf8') for x in row])
return filtered_rows
def filter_col_by_string(field, filter_condition):
dolce_gabbana = []
for row in the_data:
if field == "Dolce & Gabbana":
dolce_gabbana.append(row)