Pages

Creating IOCTL linux kernel 5.3


Code for creating IOCTL command in linux kernel 5.3 . The details of creation and usage of kerenl is given in the post here

Creating a copy of a spreadsheet having only unique rows from a given sheet


Let us say we have the following sheet which has the repeated values highlighted in bold. The following script can be used if we want to create a new sheet having rows with the repeated values of the column ID removed.



The value of file1 points to the original file and copy is the path to the new file to be created.



Save the file as create_sheet_unique_rows.py and execute it.



The new file created should look as below.


Copy rows from one spreadsheet to new one based on columns in a spreadsheet

If we want to copy  the rows from one spreadsheet to a new file based on values in another file, for example we have the files listed below.


                   
                                                File1                                                                                File2



    If we want to create a new file which has the rows of File1 only for those ids which are present in file2 we can use the following pyoo script.

Steps for installation of pyoo has been given here.

Before executing the script, we have to ensure that libreoffice is listening to the pyoo by running the following command


In the script below, file1points to the file with source data ,file2 points to the file which has the reference values based on which we want to copy and copy points to the file which will be created. Update the paths respectively.



Save the script as create_copy.py and execute it.



We should see the following file by the name given in the copy path.



Librecalc automatic grading of columns

We can use the following Pyoo based python script to automatically assign grades based on CGPA values in a column.
For example, consider the following file with CGPAs listed in the column B



If we want to assign grades based on  the CGPA values, we can use the script attached.



The script needs Pyoo to be installed, the steps for the same can be seen here .

Please note that to be able to run the script the following command needs to be run in the terminal,

  
 






If the script is saved as column_grade.py run the script from the terminal.



The file should get updated and look as below.


Python Pyoo based script to find the unique elements in a librecalc column

The following is pyoo based python script will be able to list all the unique values in a given column of a librecalc. For example if we have the following file


If we want to find all the unique terms in the column num, just run the following script. Ensure that the path variable is initialized to the full path pointing to the librecalc file.  The script requires pyoo installed, the steps for which are listed here.

Before running the script, make sure to run the following command.







Saved the script as unique_items.py, and execute it. For the above example file shown, we get the following output.

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.

from base import Element, Css, Payload, UnoBaseFeature, UnoBaseField ImportError: cannot import name 'Element'

While trying to use pyoo if the importing pyoo



throws the following error



Two possible workarounds for this are

install python3-uno if its already not installed



If after installing this the error still persist, it could be because another package by the name uno, not related to libreoffice has been installed which is causing a conflict. So uninstall the package and try it.




Create a 300DPI image using gimp

To be able to print high resolution graphic images its preferred to have the pictures of 300 dpi. We can create the 300dpi images using GIMP .

Click on



The following image will pop.



Click on the advance options. To open the following window.



Enter 300 in the X and Y resolution with pixels/in chosen and click on "OK".

The image created will be of 300X300 dpi.