Deleting a row in child table

So in my use case, I populate a child table ‘childtab’ of a doctype ‘maindoc’ with values from the back-end when another doctype gets saved. Now this child table may have empty rows . I would like to write a script ( js or py ) such that if the child table has any empty rows it simply deletes them and stores only non-empty rows.
Note: i can make the fields mandatory but it will give an error if the rows entered in child table are empty. In short i should be able to insert a document (from back-end) with child rows empty, but another script should remove those empty rows.

Edit: I came across


Has someone used this? What arguments does it take? Does it serve my purpose?
Thank you!