Thread: file io

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    2
    Rep Power
    0

    Cool file io


    problem: I need to extract a numerical string from an excel worksheet, there are approx 200 worksheets in one folder the string is in the same location on each work sheet what is the best way to code this.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    You can do it quite easily using COM automation with the PyWin32 extensions (formerly called Win32All) which you can download from https://sourceforge.net/projects/pywin32/.

    I suggest you get hold of the book "Python Programming on Win32" by Hammond and Robinson, since it has a whole chapter on controlling Excel from Python.

    Dave - The Developers' Coach
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Alternativly, since you know where the value you want is within the file. You could always open the file, grap be value (using a slice or whatever) and convert it to and int(). Though i think what Dave said is probably the way to go.

    Mark.
    programming language development: www.netytan.com Hula

  6. #4
  7. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    The data is not going to be easy to find by scanning the file and impossible if it is the result of some calculation.

    You need to extract the data after the spreadheet has been "rendered".

    DevCoach's solution is the only practical python way.

    grim

IMN logo majestic logo threadwatch logo seochat tools logo