Search

Python based Pyoo script to add all elements of a column in librecalc


The following is a script in pyoo, to add all the numbers in a column by taking the column header as an input from the user.
For example, let us say we have a file a shown below.


The scripts calculates the sum of numbers in the column whose header is mentioned by the user, for example "num" in this case, and updates the sheet with the sum in the row after the numbers and also puts the formula for the same in the cell.

To be able to run pyoo, the package has to be installed. The steps for installation are given here

 


Save the script as pyoo_column_sum.py. Make sure that the variable "path" has been intialized to point to the file where the librecalc file is located.
Run the following command before executing the script.



Note that because of the headless being added at the end of the above command, the window of librecalc will not be launched, the headless option can be removed if the window is required.

Now we can run the script (Note that the script has been tested on python3.6).




 
We can note that hte sheet has got updated with the sum of the numbers in the column and the required formula also has been updated in the sheet.

No comments:

Post a Comment