Python 3.3.3 excel read problems using xlrd

A forum for general discussion of the Python programming language.

Python 3.3.3 excel read problems using xlrd

Postby danimal » Wed Jan 22, 2014 6:05 pm

I'm new to python and new to the forum, though I have had programming experience using many other programming languages in the past as an EE student. With that said, I am not that great at programming in general, just enough to get by when I need it. But now I am transitioning over to a new position at my job where python will help out immensely so I am trying to learn on a need based method.

My setup:

Python 3.3.3
xlrd-0.9.2
xlwt3-0.1.2
pyexcelerate-0.4.1
setuptool-2.1

First problem: xlutils-1.7.0 would not install no matter what I did. I used the command prompt and installed it the same way as all of the other packages, but it returned an error. Feeling that I did not need it yet I moved on.

Second problem: Using xlrd, I can not import an .xls or xlsx file in any meaningful way. I have tried verifying encoding, but even when I change encoding I seem to get the same output. Example output as seen in Python 3.3.3 Shell:

<xlrd.book.Book Object at 0x0108DF90>

What I have:
Calling from PyExcelerate I can write, manipulate and save .xlsx files with no problem. I just need to figure how to import the data from .xlsx files in a way that I can assign cell by cell block values as variables and rewrite them onto another file. I am compiling information from a list of excel files and want to arrange data for a report that will be saved as an excel file. I have just began to get all of this together, but here is what I have so far:

Code: Select all
from mmap import mmap,ACCESS_READ
from xlrd import open_workbook

print (open_workbook('simple.xls','rb')
with open('simple.xls','rb') as f:
    print (open_workbook(file_contents=mmap(f.fileno(),0,access=ACCESS_READ)))


The above code seems to output a similar value to the shell as I listed above, twice. As you can see this is adjusted code from the python-excel.org examples, adjusted for python 3 syntax. I have gone through tutorials, and the library for literally every term in the code to verify all input methods and conditions. I don't know what I am seeing, and being new to the language I am having a hard time decoding what the output is derived from. Thanks in advance for you help.
Last edited by Yoriz on Wed Jan 22, 2014 6:22 pm, edited 1 time in total.
Reason: First post lock
danimal
 
Posts: 2
Joined: Wed Jan 22, 2014 5:32 pm

Re: Python 3.3.3 excel read problems using xlrd

Postby Yoriz » Wed Jan 22, 2014 6:43 pm

Hi
You need to carry on reading the tutorial
The code you have shown is from page 7, and shows how to get a book object that you then use to obtain the infomation from that workbook.
Carry on with the tutorial pdf and it will show you how to use the book object.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 789
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Python 3.3.3 excel read problems using xlrd

Postby danimal » Thu Jan 23, 2014 3:06 pm

Yup, I'm dumb, it worked fine. I just was hung up getting an unexpected result and did not want to move on. Thanks for the quick response.
danimal
 
Posts: 2
Joined: Wed Jan 22, 2014 5:32 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 3 guests