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

Hello,

I have set up my spreadsheet in Datavyu to code three dependent measures in one column called help. This way, each cell provides all of the information for one measure. The cells include codes for "event"; which is the type of measure, "yesno", to describe if the participant helped or not; and "how", to describe how the participant acted.

I've managed to create a script to export all of the data, and the data appears in time order as expected. However, I would like to structure the file so that all of the data associated with a specific measure occurs in the same group of columns (all of the measures for measure 1 are in the first columns, regardless of the order the participant completes the measures). Is this possible?

I've tried to restructure my script using if/else statements, but it returned a blank .csv file. I tried to restructure it again, and I received a "No Methods" error (script below). Do you have any ideas?

Thanks! Amanda

require 'Datavyu_API.rb' begin out_file = File.expand_path("~/Desktop/SH043015.csv") out = File.new(out_file,'w') filedir = File.expand_path("~/Desktop/SH Coding/") filenames = Dir.new(filedir).entries for file in filenames if file.include?(".opf") and file[0].chr != '.' puts "Please hold..." + filedir+file $db,proj = load_db(filedir+ "/" +file) puts "YAY! Videos loaded correctly :)"

  subjinfo = getColumn("Subj_Info")
  help = getColumn("help")
     for scell in subjinfo.cells
        out.write(scell.subj+ ","+ scell.sex + "," + scell.age + "," + scell.first + ",")
       for hcell in help.cells
           out.write(hcell.onset.to_s[0] + ", " + hcell.offset.to_s[0] + ", " + hcell.event[0] + ", " +  hcell.yesno[0] + ", "  + hcell.how[0] + ", ")
           if scell.first == "n"
              out.write(hcell.onset.to_s[1] + ", " + hcell.offset.to_s[1] + ", " + hcell.event[1] + ", " +  hcell.yesno[1] + ", "  + hcell.how[1] + ", "+ 
                 hcell.onset.to_s[2] + ", " + hcell.offset.to_s[2] + ", " + hcell.event[2] + ", " +  hcell.yesno[2] + ", "  + hcell.how[2] + ", ")
           else
              out.write(hcell.onset.to_s[2] + ", " + hcell.offset.to_s[2] + ", " + hcell.event[2] + ", " +  hcell.yesno[2] + ", "  + hcell.how[2] + ", "+ 
                 hcell.onset.to_s[1] + ", " + hcell.offset.to_s[1] + ", " + hcell.event[1] + ", " +  hcell.yesno[1] + ", "  + hcell.how[1] + ", ")
        end
     end
  end
  out.write("\n")

end puts "Done!!!" end end

asked 19 Jun '15, 12:42

amandaw's gravatar image

amandaw
16114
accept rate: 0%


Hi Amanda,

It sounds like you want to sort help column cells by the event code. This is the easiest way if you can ensure that every file will have one cell for each event code (if not, it's still possible but will require more work in the script).

Try doing a regular print, but instead of doing for hcell in help.cells use


for hcell in help.cells.sort_by{ |cell| cell.event }
    #place your print code here
end

Let me know if this works/doesn't work or if this is not what you want.

permanent link

answered 19 Jun '15, 13:33

Shohan%20Hasan's gravatar image

Shohan Hasan ♦♦
381126
accept rate: 12%

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:

×46
×24

question asked: 19 Jun '15, 12:42

question was seen: 2,242 times

last updated: 19 Jun '15, 13:33

powered by OSQA