I am working on a project that requires a CSV file to be read into a multidimensional array. I loop through the array, and set multidimensionalarray[x][n] to the corresponding data in the CSV file, but I keep getting IndexError: list index out of range. I can't figure out why, and I've tried a number of different ways to fix it. Naturally, I took to the internet and found several forum posts that were almost, but not quite applicable to this. The code is as follows:
def load():
x = 0
if not os.access('Database.csv', os.F_OK):
commands.getoutput('touch Database.csv')
file = csv.reader(open('Database.csv', 'rb'))
for row in file:
retArr[x].append([])
retArr[x] = row
x = x + 1
return retArr
Any help or pointers to where I might get the information would be greatly appreciated.