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

I have 72 MacSHAPA files with 4 columns of coded data. How can I convert these files into OpenSHAPA and continue to code (using the already coded information onset/offset, codes)?

Thank you!

asked 04 Nov '11, 02:21

LanaKarasik's gravatar image

LanaKarasik
81111115
accept rate: 0%


The script below (courtesy of Jesse) will convert a directory of MacSHAPA files on the desktop to a directory of OpenSHAPA files on your desktop. Like all other scripts, the code below (from begin to end) must be placed at the bottom of the API in a .rb file. You can edit the path of the directory if you don't want to run them from your desktop. This script will convert all of your files, so you only need to run it once. It doesn't matter what OpenSHAPA file is open when you run the script.

begin

# Edit this to match the directory containing your files.
macshapa_folder = File.expand_path("~/Desktop/MacSHAPA/")
macshapa_files = Dir.new(macshapa_folder)

# Edit this to match where you want to save the openshapa folders.
openshapa_folder = File.expand_path("~/Desktop/OpenSHAPA/")
if (!File::directory?(openshapa_folder))
    Dir.mkdir(openshapa_folder) # Make this dir if it doesn't exist
end

for f in macshapa_files.each()
 # Filter out files we don't want
     if (f[0].chr != '.') # Filter out the hidden files like . and .. and .DSSTORE
         puts "Converting " + f
         # Load the file and don't draw it to the screen
         $db, proj = load_macshapa_db(macshapa_folder + '/' + f, false)
         puts "Saving file " + f + " as OpenSHAPA file."
         save_db(openshapa_folder + '/' + f + ".opf")
     end
end

end

permanent link

answered 04 Nov '11, 02:29

JohnFranchak's gravatar image

JohnFranchak ♦
3964410
accept rate: 17%

edited 04 Nov '11, 02:30

Should this script still work? Can someone point me to the OpenSHAPA API referenced in this answer?

(23 Nov '13, 15:17) reising1 reising1's gravatar image

You might be able to just add the line require 'OpenSHAPA_API.rb'

Similarly, you can do this in datavyu, adding the line require 'Datavyu_API.rb'

After the require, put the rest of the code in between a 'begin' and 'end' command.

If you need the full Openshapa API, you can find it in the examples here: https://github.com/smidget/OpenSHAPA-Example-Scripts

But I would recommend doing this in datavyu and using the datavyu API, because openSHAPA is deprecated.

(23 Nov '13, 15:32) JohnFranchak ♦ JohnFranchak's gravatar image

Hi, thanks for your suggestion. I indeed used Datavyu, added the "require" line, and inserted the code between "begin" and "end" commands. When I ran the code, I see output in the Scripting Console saying "Converting WST 005" but 20 minutes later, I still don't see the "Saving WST 005 as OpenSHAPA" output that, according to the script, I should see. And I don't see the converted file on my disk. No additional output in the Scripting Console is given. What could be the problem? Does it really take more than 20 minutes?

(19 Dec '13, 16:32) reising1 reising1's gravatar image
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:

×1

question asked: 04 Nov '11, 02:21

question was seen: 3,843 times

last updated: 19 Dec '13, 16:32

Related questions

powered by OSQA