Grasshopper

algorithmic modeling for Rhino

Hi. 

Does anybody have experience with writting to Excel through GH_Python?

I can't really figure out how to install a package and tutorials that will allow me to write to an Excel sheet?

Any ideas?

Best regards Rasmus

Views: 4226

Replies to This Discussion

Hi Rasmus,

While it is possible to interact dynamically with Excel using IronPython in Rhino, I personally prefer using the Python xlrd/xlwt modules. These are both fairly easy to implement and have the advantage of being cross-platform and compatible with Libre/Open Office as well. Hope that helps.

Best,

Anders

Hi Anders.

Yes I looked into the xlrd/xlwt modules, I just could not succed in installing them? If you have time and could make a short checklist or recipe, I would really appreciate that. I tried to follow the tutorials but I could'nt make it work.

Thanks.

Rasmus

 

No problem. I have attached the xlrd/xlwt modules in a zip file.

To install the modules you simple  unzip and add them to a directory which is read by Rhino.Python. To check and modify these directories:

1) In Rhino type in the command "EditPythonScript".
2) In this Python editor go Tools -> Options -> Files.

Here you will see an overview of the directories which are currently used.

3) Add your own directory (I would recommend C:\RhinoPython).
4) Move the folders xlrd and xlwt to this directory.
5) To check that the install worked you can type this into the Python script editor:

import xlrd
import xlwt

If this does not throw any errors you should be good to go.

Attachments:

Cool Anders. That worked like a charm.

Now I just need to figure out how it works. I guess I'll have to use some time with the manual. I have a a bit difficulties figuring out how to read from a specific file path.

 

Thanks for helping me out once again. I owe you a beer one day.


Rasmus

You can use a Grasshopper File Path parameter to quickly reference a file as a string (note that the Excel file should be saved as .xls). See the attached files. No worries, I'll be sure to hold you to that when I'm back in Denmark ;)

Attachments:

Thanks.

Is it so that It is not possible to read .xlsm files? I don't seem to be able to do that.

I just tested now and it works up to Excel 97-2003,

I would be also intersted to find out how to use it on Excel from version 2007? 

While I haven't tried it myself, it does looks like the latest xlrd update supports .xlsx files (I believe this is the default Excel 2007 format). If not, you might want to check out this module instead..

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service