Please use our GitHub Issues page for all new support inquiries. If you need to contact us directly, please e-mail [email protected]


I am trying to become familiar with OpenSHAPA and find the best way for the lab to export data. I am playing around with the CSV format simply because of it's simplicity. The biggest problem I am having is exporting multiple pieces of data from the same cell into different columns of the .csv file. For example, I would like an OpenSHAPA cell to say (123, abc, circle) and to have the .csv file write "123", "abc", and "circle" into different columns. Is this possible? I can not get OpenSHAPA to even allow me to type a comma into the cell. I have also started writing scripts for nested dumps, so maybe it would be better to peruse that option...

Thank you!!

asked 17 Nov '12, 07:47

Kelley's gravatar image

accept rate: 0%

(1) The first step to getting multiple arguments (the items coded into a cell) to print to a CSV file is to set them up in your OpenSHAPA coding file. The best way is to set up a template that has all of your columns and arguments specified, so you don't need to create these anew with each file.

When you make a new variable, choose "matrix" as the column type. A matrix is just a series of different arguments separated by commas.

Now, select the new column you've made and in the menu go to Spreadsheet>Vocab Editor. You will see your new column listed and inside the parentheses will be a single argument named "arg0." You can highlight this argument and type a new name. When it's highlighted, you can also change the type for the argument—below "Add matrix()" is a drop-down menu that says "Nominal". You can keep it as a Nominal (if the coder is entering a single word or letter as the code) or change to Float if you want to enter a number with a decimal (or Integer if it will be a non-decimal number) for the code.

To add another argument to this cell, while the variable is highlighted now click "Add ". This will create a new argument to the right of the initial argument, which you can rename or change the type as needed. Keep adding arguments until you have everything you want to code entered. If you want to change the order (to add in ease of coding), the "Move " buttons with arrows will move them left and right. And there is a delete button if you need to remove an argument.

(2) The easiest way to work with outputted data is probably as a tab delimited text file, which can paste or import to Excel, SPSS, or other statistics package easily. I've pasted a bit of scripting below that might be helpful.

First, we get the variable(s) we want from OpenSHAPA and define a variable from it. In this example, I have a column called "id" where the coder enters all of the identifying information about the subjects and test session.

id = getVariable("ID")

Now, we define where we want to txt to print to, and what to call it:

dir = File.expandpath("~/Desktop") outfile = + "/ExampleIDData.txt", "a")

The basic principle to get access to all of the arguments of a cell is to first define a variable in the script that pulls all of the cells in a column:

for idcell in id.cells

"idcell" is the name of the new variable I have defined and "id.cells" is all of the cells in the id column in OpenSHAPA.

Finally, we write to the outfile:

out_file.syswrite ( + "t" + + "t" + + "t" + idcell.cond + "t" + idcell.tdate + "t" + idcell.bdate + "t" + idcell.coder + "t" + idcell.relcoder + "r" )

The "outfile.syswrite" command will write whatever we define to the outfile location we specified earlier. Within the command, since we defined our variable "idcell," we can pull what was entered for each of the arguments by name. For example, "" will pull the study name argument, "idcell.cond" pulls the condition number argument, etc.

Between each argument I have a "+" which means to add something to our text file, and then I put a "t" which is the command for a tab. We keep going adding argument names, +, and t until we are done. The last item is "r" which is a return line (enter key) to have any need data written to this file start on a new line (if you're exporting data from multiple files).

Let me know if you encounter any problems. Scripting just involves a lot of playing around to get good. You can also upload or paste the script that you're trying to use and I can give more detailed help.

Here is the whole script together:


id = getVariable("ID")

dir = File.expandpath("~/Desktop") outfile = + "/ExampleIDData.txt", "a")

for idcell in id.cells

out_file.syswrite ( + "t" + + "t" + + "t" + idcell.cond + "t" + idcell.tdate + "t" + idcell.bdate + "t" + idcell.coder + "t" + idcell.relcoder + "r" )



permanent link

answered 20 Nov '12, 01:38

KCSoska's gravatar image

KCSoska ♦
accept rate: 17%

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: 17 Nov '12, 07:47

question was seen: 7,201 times

last updated: 18 Jun '13, 23:10

powered by OSQA