for my course I need to create a function that opens a csv file, reads it, creates a 2D list and that gives the list a name. There are several csv files so the idea is that I refer to the read_file function and input the file name parameter. See image for code. I cant seem to input the file name an a parameter. Any help?
function attempt:
CodePudding user response:
In addition to the already posted comments, you then need to un-quote the filename after the with open
. Since if you now call with file_name as a string already, you need the quotes there anymore. So like this:
def read_file(file_name):
....
with open(file_name, 'r', ...) as f:
...
read_file('kameraData.csv')