Newbie: Reading and printing cells from excel
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
jrara <johannesr... @gmail.com>
Date: Wed, 28 Oct 2009 05:12:53 -0700 (PDT)
Local: Wed, Oct 28 2009 11:12 pm
Subject: Newbie: Reading and printing cells from excel
Hi,
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)
TypeError: 'list' object is not callable
What I'm doing wrong?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Георги Георгиев <georgi_georg... @directservices.bg>
Date: Wed, 28 Oct 2009 14:26:25 +0200
Local: Wed, Oct 28 2009 11:26 pm
Subject: Re: [pyxl] Newbie: Reading and printing cells from excel
try
print sposti[i] + ';'
hope this helps :-)
jrara wrote:
> Hi,
> 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)
> TypeError: 'list' object is not callable
> What I'm doing wrong?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
John Machin <sjmac... @lexicon.net>
Date: Wed, 28 Oct 2009 23:30:24 +1100
Local: Wed, Oct 28 2009 11:30 pm
Subject: Re: [pyxl] Newbie: Reading and printing cells from excel
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
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
johannes rara <johannesr... @gmail.com>
Date: Wed, 28 Oct 2009 15:08:04 +0200
Local: Thurs, Oct 29 2009 12:08 am
Subject: Re: [pyxl] Re: Newbie: Reading and printing cells from excel
Thanks, that solved the problem!
- Johannes
2009/10/28 Георги Георгиев <georgi_georg... @directservices.bg>:
> try
> print sposti[i] + ';'
> hope this helps :-)
> jrara wrote:
>> Hi,
>> 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)
>> TypeError: 'list' object is not callable
>> What I'm doing wrong?
You must
Sign in before you can post messages.
You do not have the permission required to post.