Question

All,

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

From a mapping/GIS/analysis standpoint: the simplest example would be a script that ran a buffer (proximity) tool on a given shapefile (GIS dataset).

For the buffer distance parameter, instead of just using a number like '1000' feet, 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!!!

(also posted here: https://gis.stackexchange.com/questions/49288/can-python-read-the-value-of-a-cell-in-a-spreadsheet)

-mb

Was it helpful?

Solution 2

There are a few great Python-Excel tools available: http://www.python-excel.org

OTHER TIPS

pyoo is a simple package. Install

python-uno
python3-uno

Then install pyoo

python setup.py install
python3 setup.py install

run soffice (LibreOffice or OpenOffice)

soffice --accept="socket,host=localhost,port=2002;urp;" --norestore --nologo --nodefault # --headless

The following script shows how it works in python

desktop = pyoo.Desktop('localhost', 2002)
doc = desktop.open_spreadsheet(path)
sheet = doc.sheets[0]
for i in range(0,14):
  for j in range(0,4):
    print(sheet[i,j].value)

It's all great but soo vague. Where do you execute the install command? And even if you somehow figure out you have to go to the pip3.6.exe excript and run it from there, it won't find python3-uno. It will fin python-uno but even then you won't run any script with import uno in the beginning because of missing elements, which are somehow impossible to get. It is stupidly hard to do even the simplest thing this way in LibreOffice.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top