Announcing the new Datavyu v1.3.6 with enhanced features and transcription support!

I'm working with a simple data set in which I'm using two nested columns. I'll call them column A, which has one cell close to the length of the entire session, and column B, where for about half the files, we're coding short bouts of target behavior. However, for some cases, our participants don't ever exhibit the behavior of interest. So we have data in column A but nothing in column B.

Is there a way to write a script that will export both column A and B for cases where we have data in both columns, and just one row with the column A data for cases where we have no cells in column B?

Would it be simpler to create one cell in column B to the right of the one cell in column A, and just enter "." for all arguments?

asked 23 Jan '14, 21:10

LisaHurwitz's gravatar image

LisaHurwitz
31447
accept rate: 0%


script attached below, please change file directories and column names as necessary. i'll send you the sample spreadsheet as well.

require 'Datavyu_API.rb' begin

filedir = "/Users/motoruser/Desktop/sample/"
filenames = Dir.new(filedir).entries

dir = File.expand_path("~/Desktop")
out_file = File.new(dir + "/sampleprint.txt", "w")

for file in filenames
    if file.include?(".opf") and file[0].chr != '.'

        puts "LOADING DATABASE: " + filedir+file
        $db,proj = load_db(filedir+file)
        puts "SUCCESSFULLY LOADED"

        columnA = getVariable("columnA")
        columnB = getVariable("columnB")

        for acell in columnA.cells
            withinacell = Array.new # we put all bcells that nest within the current acell into a new array
            for bcell in columnB.cells
               if bcell.onset >= acell.onset and bcell.offset <= acell.offset
                   withinacell << bcell
               end
            end
            if withinacell.length == 0 # if there arent any cells that nest
                out_file.syswrite(acell.arg01+"\\t"+"."+"\\t\\n")
            else
                withinacell.each do |thiscell|
                    out_file.syswrite(acell.arg01+"\\t"+thiscell.arg01+"\\t\\n")
                end
            end
        end
    end
end

end

permanent link

answered 24 Jan '14, 16:22

GladysChan's gravatar image

GladysChan ♦♦
164116
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×24
×6
×2

question asked: 23 Jan '14, 21:10

question was seen: 2,747 times

last updated: 24 Jan '14, 16:22

powered by OSQA