Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
    
This seems only tangentially related to GIS, perhaps better asked at stackoverflow.com. –  blah238 Jan 28 '13 at 18:51
    
Thought I'd start here...but will post over there just for kix. –  mapBaker Jan 28 '13 at 19:13
1  
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! –  mapBaker Jan 29 '13 at 15:07
show 1 more comment

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.

2 Answers

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: stackoverflow.com/questions/5413449/… –  Mike T Jan 28 '13 at 22:37
add comment

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
excel=client.Dispatch("Excel.Application")
excel.Visible=True
book=excel.Workbooks.Open("c:/desktop/test.xlsx", False, True)
sheet=book.Worksheets(1)
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! –  mapBaker Jan 29 '13 at 15:43
add comment

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