with the line that starts with ###TODO def load_csv_data(filename): """ load the data from csv file returns a tuple containing two lists: col_names: first row of csv file (list of strings) row_data: all other rows of csv file (list of list of strings) if error is encountered reading filename, returns -1 """ try: data = [] ### TODO - load the data from csv file ### use csv.reader to append rows of filename to data
IN PYTHON - please please please help with the line that starts with ###TODO
def load_csv_data(filename):
"""
load the data from csv file
returns a tuple containing two lists:
col_names: first row of csv file (list of strings)
row_data: all other rows of csv file (list of list of strings)
if error is encountered reading filename, returns -1
"""
try:
data = []
### TODO - load the data from csv file
### use csv.reader to append rows of filename to data
except:
print("Error loading data.")
return -1
# if successful, return tuple of column names and row data
col_names = data[0]
row_data = data[1:]
return (col_names, row_data)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps