Announcing the new Datavyu v1.4.0 with enhanced features, bug fixes, and a new video player for Windows!

We are in the process of migrating away from this forum—feel free to browse existing help topics. For new support inquiries, please reach out to us via email at [email protected]

Hello, I've coded 3 column (with onsets and offsets and 1-2 arguments within the cells). The cells across the columns sometimes overlap. I would like to create 1 column which combines all times from the 2 or 3 columns and creates mutually exclusive codes/categories. Is there a way to do this with a script?

I would like to know how to best to deal with and rename the arguments after creating the new column. Though, another question, what does it mean that the new variable/column is not set back into the spreadsheet? This is the script I used:

mutex = create_mutually_exclusive("mutex", "timelocation", "timesleep") setVariable("mutex",mutex)

Thank you!

asked 22 Jul '13, 14:17

LanaKarasik's gravatar image

accept rate: 0%

edited 31 Jul '13, 20:35

Jesse's gravatar image

Jesse ♦

Yes, there is. In fact you can do it with one line:

newvariable = create_mutually_exclusive("NewVariable", "OldVar1", "OldVar2")

Note that this creates the new variable, but doesn't save it back into the spreadsheet for you to look at. You can chose to save it back or not.

This mutex function will create one variable with information from both columns. Each cell in the new variable will have all the arguments of the original cells, and the ordinals of the original cells. So for example, if each column (named Column 1 & 2 let's say) had one argument (named arg1), the cells in the new will have the following information: column1_ordinal, column1_arg1, column2_ordinal, column2_arg1. All the values from the original cells will be copied into those fields, and the ordinal lets you identify which cell the data came from.

To combine three columns, you'll want to use mutex twice: Once, to combine the first two columns, then again to add the third in. The names of the variable might get quite long though as it appends the names together, so you may want to rename them.

If you need more help using the function (or want to know how to set the new variable back or rename arguments) just let us know.

If you don't set the mutex variable back, you can do things with it in scripting (print it for example) but you won't see it in the spreadsheet. Basically, the new mutex variable exists in ruby-scripting land, but it's not actually in the spreadsheet until you set it using setVariable (which you already have in the code you posted). Often you may not need to save it back to your spreadsheet - it may work just fine to have the mutexed variable be created fresh each time you run your script. Setting variables works the same way when making changes to variables in your spreadsheet: Once you've made a change to a variable through a script, it won't save those changes back into the spreadsheet until you use setVariable. It's as though you have a working copy of the variable; if you want to keep that working copy, you have to save it back into the database.

To change argument names, use the following (it doesn't have to be in a loop or anything):

variablename.change_arg_name("OldArgName","NewArgName") So the steps are: 1) Get your variables, 2) Mutex them together, 3) Rename arguments if desired and/or set the new mutex variable if you want to look at it in the spreadsheet, 4) Use your new mutex variable just as you would any existing variables in the spreadsheet (to print, whatever). The rest of the script will be just like any other script, it just has one additional step at the beginning (creating the mutex variable).

permanent link

answered 23 Jul '13, 12:10

WhitneyCole's gravatar image

WhitneyCole ♦
accept rate: 21%

edited 31 Jul '13, 20:36

Jesse's gravatar image

Jesse ♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 22 Jul '13, 14:17

question was seen: 20,633 times

last updated: 31 Jul '13, 20:36

powered by OSQA