??? Whats there ???
There is a Pandas for LibreOffice extension, which also installs numpy.
If Pandas is not needed there is Python Numpy Extension.
Both of those extensions will install into Windows, Mac, Linux, Flatpak, Snap.
Also Have you tried installing using zaz-pip it is very good at installing python package into Linux, Mac and windows. Should handle also handle Flatpak and Snap installs.
See Also Pip & Virtual Environments guides.
@vib It will hardly help a beginner who has problems with his manageable python setup, if you provide him with links to your very own overkill solutions!
OK, I have been thinking a lot about this over night (thank you so much for your help I really do appreciate you taking the time to help me out as I get my head around all this)…and I can see you are right that I should move to an external (to LO) environment…however how would you handle (in an external environment) a script that you run on various pages in a file…and different pages each time. Within LO you just go to the sheet and run the script. If you were outside LO, would you not have to edit the script each time put the address of the sheet in the file before running…that seems like a lot of duplication! What am I missing?
OK, I got HelloWorld.py to work! Yeah! I am on a roll!
OK, I have set up my external environment (actually I had set it up earlier but had not really used it much).
Now how to connect it to Geany?
/home/yodap/Python_Projects/PPScriptorium/HelloWorld.py: 1: import: not found
/home/yodap/Python_Projects/PPScriptorium/HelloWorld.py: 2: from: not found
/home/yodap/Python_Projects/PPScriptorium/HelloWorld.py: 4: Syntax error: “(” unexpected
(program exited with code: 2)
Blockquote
import ezodf
from pathlib import Path
def main():
ods_path = Path.home() / “Documents” / “hello.ods”
print(f"the path: {(p:=ods_path)} {‘already exists’ if p.exists() else ‘’ }")
# Load the ODS file
doc = ezodf.opendoc(f’{ods_path}’)
# Get the first sheet
sheet = doc.sheets[0]
# Set the string in cell A1
sheet[‘A1’].set_value(“Hello World”)
# Save the changes
doc.save()
if name == “main”:
main()
Hmm, I thought I was doing so good. This was the result of running the code in Geany
Thank you all, through your help and pointers I have found elsewhere I am now up and running with Geany! I huge thank you to you all!
Now the only thing which mystifies me is how would you handle (in an external environment) a script that you run on various pages in a file…and perhaps different pages each time…but carries out the same set of commands. Within LO you just go to the sheet and run the script. If you were outside LO, would you not have to edit the script each time put the address of the sheet in the file before running…that seems like a lot of duplication! What am I missing?
I am not really clear on what you mean here but I am assuming you want preform operetions on all the sheet for a Calc Document.
If so, could you not just get access to all the sheets in the doc and preform the actions.
Here is pseudo code that to show what I am thinking.
for sheet in doc.sheets:
# do some actions on this sheet.
cell = sheet["A1"]
cell.value = 10
# ...
Suppose I am managing a number of factories. Each factory has a separate sheet in the Factory File. As new information comes in on each factory - at different times of the year…about output, workers, efficiency, profit etc. I want to do a series of calculations on the latest numbers to see how the factory is doing. Not all factories report at the same time…there could be 3 months of a gap before the numbers come in. So I want to do the calculations on the latest set of numbers. From inside LO I can just go to whichever sheet and run the update script on it. But from outside LO, I would have to put into the script the address of each of the individual sheets that I want to update. That seems really cumbesome!
How about add a command line option that can take sheet names, or a config file such as JSON that contain the docs/sheets that need to be updated.
for doc_name in config.docs:
doc = CalcDoc.load_doc(doc_name, visible=True)
sheet_names = config.get_sheets(doc_name)
for sheet_name in sheet_names:
sheet = doc.sheets.get_by_name(sheet_name)
doc.sheets.set_active_sheet(sheet) # activate if needed
# do work
doc.close()