On 28/10/2009 11:12 PM, jrara wrote:
> Hi,
Hi jrara, welcome to the group.
> I'm python newbie but I'm trying to read data from Excel file (from
> one column) and print it into the output. Here's my code:
> ------------- python code -----------
> #!/Python26/
> # -*- coding: utf-8 -*-
> import xlrd
> wb = xlrd.open_workbook('testiexcel.xls')
> #Get the first sheet either by name
> sh = wb.sheet_by_name(u'data')
> sposti = sh.col_values(8)
> for i in range(sh.nrows):
> print sposti(i) + ';'
> ------------- python code -----------
> I get an error
> Traceback (most recent call last):
> File "Read_xls_files.py", line 18, in <module>
> print sposti(rownum)
There is no line "print sposti(rownum)" in the code listing. Please when
you are reporting an error, make sure that the code that you show is the
code that you ran.
> TypeError: 'list' object is not callable
> What I'm doing wrong?
Mixing up function/method calling e.g. do_something_with_this(thing) and
sequence subscripting e.g. a_sequence_like_sposti[index_expression] ...
The error message means that sposti refers to a list but you are trying
to call it like a function.
HTH,
John