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

About 4 years ago, I used to know how to use MacSHAPA and am trying to teach myself Datavyu. Whenever I try to export my data, I get the following error message:

NoMethodError: private method getVariable' called for nil:NilClass getVariable at file:/C:/Users/Paradigm/Desktop/datavyu-1.0/datavyu-1.0.exe!/Datavyu_API.rb:420 (root) at <script>:15 each at org/jruby/RubyArray.java:1615 (root) at <script>:8 org.jruby.embed.EvalFailedException: (NoMethodError) private methodgetVariable' called for nil:NilClass

Here are two different export scripts I've written that both generate the same error:

Script 1:

require 'Datavyu_API.rb'

begin

file_directory = "C:/Users/Paradigm/Documents/Datavyu"

static_dir = Dir.new(file_directory)

website_order = ["stratum", "url", "childtarg", "label", "advert"]
marketing_order = ["level", "madvert", "cat", "logo", "music", "char", "nochar"]

output_file = File.new(File.expand_path("C:/Users/Paradigm/Documents/Datavyu/Output.txt"), 'w')

header = website_order + marketing_order
for h in header
    output_file.write(h + "\\t")
end

output_file.write("\\n")

for file in static_dir

    if file.include?(".opf")

        puts "Opening", file
        $db,proj = load_db(file_directory + file)
        puts "Successfully Loaded"

        website = getVariable("website")
        marketing = getVariable("marketing")

        for websitecell in website.cells
            for marketingcell in marketing.cells
                if websitecell.onset <= marketingcell.onset and websitecell.offset >= marketingcell.offset
                    print_args(websitecell, output_file, website_order)
                    print_args(marketingcell, output_file, marketing_order)
                    output_file.write("\\n")
                end
            end
        end
    end
end

puts "Finished"

end

Script 2:

require 'Datavyu_API.rb'

begin

file_directory = "C:/Users/Paradigm/Documents/Datavyu"
filenames = Dir.new(file_directory).entries

for file in filenames
    if file.include?(".opf")

        puts "Opening " + file
        $db,proj = load_db(file_directory + file)
        puts "Loaded"

        website = getVariable("website")
        marketing = getVariable("marketing")

        out_file = File.new(dir + "C:/Users/Paradigm/Documents/Datavyu/Output.txt", "a")

        for websitecell in website.cells
            for marketingcell in marketing.cells
                if websitecell.onset <= marketingcell.onset and websitecell.offset >= marketingcell.offset

                    out_file.syswrite(websitecell.stratum+"\\t"+websitecell.url+"\\t"+websitecell.childtarg+"\\t"+ websitecell.label+"\\t"+websitecell.advert+"\\t"+marketingcell.level+"\\t"+marketingcell.madvert+"\\t"+ marketingcell.cat+"\\t"+marketingcell.logo+"\\t"+marketingcell.music+"\\t"+marketingcell.char+"\\t"+marketingcell.nochar+"\\n")

                end
            end
        end
    end
end

puts "Finished"

end

And this may be more information than you need, but here's the script I used to setup the variables:

require 'Datavyu_API.rb'

begin

website = createVariable("website", "stratum", "url", "childtarg", "label", "advert")


marketing = createVariable("marketing", "level", "madvert", "cat", "logo", "music", "char", "nochar")

notes = createVariable("notes")

setVariable(website)
setVariable(marketing)
setVariable(notes)

end

This should be a relatively simple thing I'm trying to do. I'd appreciate any insight you can share as to what I might be doing wrong!

asked 19 Jan '14, 17:33

LisaHurwitz's gravatar image

LisaHurwitz
31447
accept rate: 0%


I think this is an easy fix. Currently, you've set the file path where your files are located as:

file_directory = "C:/Users/Paradigm/Documents/Datavyu"

You need to add a slash at the end, like this:

file_directory = "C:/Users/Paradigm/Documents/Datavyu" + "/"

The script is crashing because as written, it thinks the file path should be C:/Users/Paradigm/Documents/DatavyuFilename.opf. It's all just one big string, so without adding the last slash in, it doesn't make sense, there's no file to load, and therefore you can't get any variables (which looks to be where you're getting the error). I'm telling you to add the slash by doing + "/" instead of just typing it in at the end of the first string because in certain situations in Windows a slash at the end of the string will get stripped out. Easier to just get in the habit of doing it this way.

permanent link

answered 23 Jan '14, 11:29

WhitneyCole's gravatar image

WhitneyCole ♦
417239
accept rate: 21%

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:

×18
×12

question asked: 19 Jan '14, 17:33

question was seen: 8,807 times

last updated: 23 Jan '14, 11:29

powered by OSQA