+ Reply to Thread
Results 1 to 6 of 6

Need help using the XLRD Module in Python to read data from an xls file and write to word

  1. #1
    Registered User
    Join Date
    06-05-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    3

    Need help using the XLRD Module in Python to read data from an xls file and write to word

    Hello,

    I have been assigned a seemingly easy task at work, and I told my boss I would do it really fast but I soon realized I don't know how the XLRD module works.
    Im trying to access data from a spreadsheet, and then write it to a word file
    I have four columns (Name, Address, URL and Details), and the output should be of the form:

    *first row
    Name - oihfdafsas
    Address- fasdfasd
    URL - nfdsknd
    Details - ksfnls

    *second row
    Name- hsdihsd
    Address- hdshsd
    URL- ksknd
    Details- ishdosd

    and so on

    How should I go about it?
    I tried some code but I got this error and I dont know why:
    Syntax Error: print "EXTERNSHEET(b7-):": C:\Python33\lib\site-packages\xlrd\__init__.py, line 99941

    Any Help would be Much Appreciated!

    Regards,
    Manik Saraf

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Need help using the XLRD Module in Python to read data from an xls file and write to w

    Manik

    I've never seen any examples that use EXTERNSHEET.

    As far as I know code to read from an Excel workbook using xlrd in Python would look something like this.
    Please Login or Register  to view this content.
    PS Is there a reason you are using Python? This could easily be done using VBA.
    Last edited by Norie; 06-10-2013 at 11:04 AM.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-05-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Need help using the XLRD Module in Python to read data from an xls file and write to w

    Hello Norie,

    I apologize for my less than prompt reply

    I am more familiar with Python, and have never really used VBA. What would the VBA script for this be?
    I used the code you provided me, but I still get the same "EXTERNSHEET" error

    On further inspection, it seems to be something that's triggered in the init method in the code for the XLRD module.

    What do you recommend?

    Thanks a Bunch!
    Manik

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Need help using the XLRD Module in Python to read data from an xls file and write to w

    Manik

    I would recommend using VBA for this.

    The code would be pretty straightforward, a simple loop, copy and tranpose.

    Mind you, that can probably all be done in Python too, though I'm not sure how.

    Do you have a sample workbook you could upload?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  5. #5
    Registered User
    Join Date
    06-05-2013
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Need help using the XLRD Module in Python to read data from an xls file and write to w

    Hey

    Oh okay, this is my first time working with Python on excel, and for some reason I keep on getting the EXTERNSHEET error. Im sure I'd be able to fix it, if only I knew what it was haha

    Yeah sure, here it is
    Attached Files Attached Files

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Need help using the XLRD Module in Python to read data from an xls file and write to w

    Manik

    Are you using 64 bit Windows and Python 3.3?

    I am and I get the error from your first post when I try to install the xlrd-0.9.2 package.

    I've also tried earlier versions of xlrd but also have problem trying to install.

    I've seen some stuff that seems to indicate the xlrd isn't available for the 64 bit/Py3.3 combination and it does seem to be the case.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1