I asked this question yesterday but am still stuck on it. I\'ve written a function that currently reads a file correctly but there are a couple of problems.
The main
You just want this:
def read_file(filename):
with open(filename, "r") as thefile:
mydict = convertLines(thefile.readlines()))
return mydict
your current function is infinitely calling itself... Then fix your convertLines
function if it needs to.
This should simplify your code a bit, however I have left dealing with the header row up to you.
from collections import defaultdict
import csv
artists = defaultdict(list)
with open('artists.csv', 'r') as csvfile:
reader = csv.reader(csvfile,delimiter=',')
for row in reader:
artists[row[0]].append(row[1:-1])