Saturday, December 11, 2010

Avoiding complex calculations in Excel

Have you ever received some data in an Excel sheet that you need to do some rather complicated computations on before you share results with other users? Sometimes, the analyses we need to do are outside the realm of a spreadsheet. Then, why not use a library that allows you to read Excel data into a data structure in your programming language of preference, do the computations, and then write back to the excel sheet? This can save you a lot of headache in maintenance and allow you to use more powerful libraries than those available in Excel. Here is an example with Python as the programming language.

First, install the package xlrd from here: http://www.lexicon.net/sjmachin/xlrd.htm. Then, you can read in data to Python, manipulate at hearts will and get your results without struggling with Excel limitations. Also install xlwt. How to use these packages is explained here: http://scienceoss.com/write-excel-files-with-python-using-xlwt/. These are excellent blog posts - don't want to rip them off, go to the source :-)

I use these packages to combine results from Excel calculations with output from other types of software, for re-entering results into Excel files for easy referencing later (and sharing with colleagues).

No comments:

Post a Comment