PDA

View Full Version : extracting info from excel


floyd1510
04-21-2009, 02:12 AM
hey all,

Is there any way I can read a list of files specified in excel and execute commands as a batch process. I need this to be done in Mel since i do not want to install any python modules on all computers.

Hope this makes sense,

Cheers,
Vikram.

Chadrik
04-21-2009, 03:25 AM
I'm not an expert in Office formats, but out of curiosity I did some searching. I found this page: http://blogs.msdn.com/excel/archive/2006/07/20/671995.aspx

It says that excel 2007 uses an Open XML format, which means you should be able to use python's built-in xml parsing modules (no need to install additional modules).

However, if you're willing to install 3rd party modules, I came across this http://code.google.com/p/openxmllib/ which would probably save you a lot of time. What is your concern with distributing modules? You have to provide these machines with your script anyway, it's just as easy to provide the machines with two files as it is to provide one...

-chad

floyd1510
04-21-2009, 04:30 AM
Thanks chad for the reply,

The problem is that in my worlplace python is not installed on the user machines and hence any python usage is resticted to what Maya provides. Hence the module distribution problem. In XSI using Javascript I just had to create an Excel object and data could be imported. Was wishing a similar approach.

Chadrik
04-21-2009, 07:25 AM
so, if you were going to write a mel script, where would you put it? on a server where all machines can see it? you can do the same thing with python. just put the two scripts -- yours and the one it depends on -- in a directory where all machines can access them. there are a number of ways that you can make sure that these files are seen by maya's python, but the most brute force way is this:

import sys
sys.path.append( '/global/python/folder')

alternately, you can set the PYTHONPATH var in each machine's Maya.env.

my point is that, there's no more need to distribute python scripts than there is to distribute mel scripts and setup-wise, its not any harder to use a python than mel.

-chad

CGTalk Moderation
04-21-2009, 07:25 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.