How do I write a script to add cells to a column in places based off cells in another column? For example, I want to add cells in column 2. I want cells to only be added in places corresponding to when cells in column 1 had "s" for the code. Could anyone help with this? |
I tried pasting the code here, but it isn't getting formatted neatly. I've got a side project going on to collect Datavyu scripts into a GitHub repo here: DatavyuScripts The two scripts of interest are Insert-SecondaryColumn.rb and Insert-TestColumn.rb. Play around with the parameters in the first script to tweak it to your needs. The second script can help you test run the script. It might be useful to set the clobber parameter in the first script to true while you are testing. That way you won't have to remove columns before re-running the script. |
Oh, and in case you want a script without all the bells and whistles:
To write your own scripts, please check out the Ruby API reference: http://datavyu.org/user-guide/api/reference.html and the associated guides. The key functions for this task are the API functions: getVariable, make_new_cell, change_arg, and setVariable. To filter out cells, I prefer to use the select function but you could also use a for loop like so:
Again, you will want to replace code01 with the actual code you want. |