Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can python read the value of a cell in a spreadsheet?

The simplest example would be a script that ran a buffer tool on a given shapefile.

For the distance parameter, instead of just using a number like '1000', the script would point to a value in a cell of a spreadsheet (libre or open office preferred).

If there was then a way to trigger the script from the spreadsheet by way of a button, that would be the next step (then the next step would be to have a map control inside the spreadsheet to see the updated results!)

Just to give some insight into where I'm going with this: I'd like to use a spreadsheet as an analysis 'dashboard' where users could run analysis with different parameters - what would proximity around parks (grocery stores, etc.) be at 1/2 mi vs 1/4 mi...then another sheet in the spreadsheet would have a breakdown of the demographics within that proximity.

Thank you!

share|improve this question

closed as off topic by blah238, whuber Jan 29 '13 at 3:50

Questions on Geographic Information Systems Stack Exchange are expected to relate to geographic information systems within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

This seems only tangentially related to GIS, perhaps better asked at – blah238 Jan 28 '13 at 18:51
Thought I'd start here...but will post over there just for kix. – DPSSpatial Jan 28 '13 at 19:13
arpcpy from ESRI treats the spreadsheet as a workspace, with each page being a table. – mhoran_psprep Jan 28 '13 at 19:30
Please don't double-post: we have a mechanism to migrate questions between sites. This creates links among them and relieves you of a duty to keep the multiple posts in sync and create the cross-links yourself. I'll close this version. – whuber Jan 29 '13 at 3:50
@whuber: I got more response here than I did with stackoverflow... Since you closed this - for some reason - I may not get further responses! – DPSSpatial Jan 29 '13 at 15:07
up vote 6 down vote accepted

Yes, use the xlrd library. See parsing excel documents with python question on Stack Overflow.

share|improve this answer
Since the question preferred libre or open office:… – Mike T Jan 28 '13 at 22:37

On windows and with MS office, you can use the pywin32com module to access the com-api (=same as VBA). This way you can also write to excel. For example:

from win32com import client
book=excel.Workbooks.Open("c:/desktop/test.xlsx", False, True)
sheet.cells(1,1).value = "some text or number"
share|improve this answer
Thank you all for your responses - I'm glad I posted here, as I knew GIS folks would have some insight into this! – DPSSpatial Jan 29 '13 at 15:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.