TypeError: 'list' object is not callable

W

wilsonmonde

import csv

date1 = []
open = []
high = []
low = []
close = []
data = []
with open("C:/Documents and Settings/wilson/My Documents/Downloads/execution.csv", "rb") as csvfile:
fastreader = csv.reader(csvfile, delimiter = ",", skipinitialspace=True)
count = 0
for row in fastreader:
date1.append(row[0])
count = count + 1


TypeError: 'list' object is not callable
 
G

Gary Herron

import csv

date1 = []
open = []
high = []
low = []
close = []
data = []
with open("C:/Documents and Settings/wilson/My Documents/Downloads/execution.csv", "rb") as csvfile:
fastreader = csv.reader(csvfile, delimiter = ",", skipinitialspace=True)
count = 0
for row in fastreader:
date1.append(row[0])
count = count + 1


TypeError: 'list' object is not callable

I'd be glad to help, but I'm not interested in guessing. Pleas take the
time to tell us what line produced that error? That is: cut and paste
the *full* traceback instead of hiding useful information when you are
asking for help.

Gary Herron
 
J

Jussi Piitulainen

Peter said:
TypeError: 'list' object is not callable
Hint:

open = []
[...]
with open(..., "rb") as csvfile:

i follow in
http://www.dyinglovegrape.com/data_analysis/part1/1da3.php

still have error

what is the correct writing?

One way:

# open = []
with open(..., "rb") as csvfile:

Commenting out the assignment statement prevents it from doing the
damage before you try to access the original value of open.

Another way:

with [](..., "rb") as csvfile:

This doesn't work any better but it makes the error stand out.

Yet another way:

avaa = open
open = []
with avaa(..., "rb") as csvfile:

That is, save the original value of open in another variable, which I
here called avaa.

The best way is to omit the whole assignment altogether. Were you
using the list called open for something?

Oh, one more way!

with open(..., "rb") as csvfile:
...
open = []

That is, only shoot yourself in the foot after the work has been done!
Though, really, best not do it at all. The page you referred to,
doesn't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top