Add Codes to a Column¶
Adding codes to a column is a straightforward
scriptable task. The Datavyu API provides the add_code() method
for adding codes.
add_code() takes the names of the Datavyu codes you are adding
as its parameters. This example adds a code
called unit to the “trial” Datavyu column in the sample
data. The unit code might
represent the unit of measure used during an experiment.
Start by setting up the script and assigning the Datavyu column “trial” to a variable using
getColumn(). You can call your variable whatever you want to. We’re calling ittrialin this example:require 'Datavyu_API.rb' begin # Retrieve "trial" data from Datavyu spreadsheet and assign it # to a new Ruby variable trial = getColumn("trial")
Add the unit code to
trialusingadd_code():require 'Datavyu_API.rb' begin trial = getColumn("trial") # Add the "unit" code to the trial variable trial.add_code("unit")
Write the changes back to the Datavyu spreadsheet using
setColumn()andendthe script:require 'Datavyu_API.rb' begin trial = getColumn("trial") trial.add_code("unit") # Write the changes back to the Datavyu spreadsheet setColumn(trial) end
