my code looks something like this:
for filename in files:
with open(filename, 'rb') as csvfile:
csvreader = csv.reader(csvfile, delimiter=';')
values=list(csvreader)
dosomething()
i have about 10 files i want to process and it works without a problem for the first file. but when python tries to start processing the second file it says
Traceback (most recent call last):
File "plot.py", line 20, in <module>
values=list(csvreader)
TypeError: 'list' object is not callable
has anybody an idea why this won’t work?
Somewhere you have used a (global, if the problem is showing up here) variable named
listto hold an instance of a list. That is a bad idea. The namelistis looked up every time it’s used, and that variable is found in preference to the actuallisttype, which is what you want (i.e. in order to construct a list from thecsvreaderresults).