N
Nathan Loyer
I am new to Ruby, but am doing my best. I have a zip file that I'm
trying to open, go to directory "word" and read one of the files out.
Here is what I have so far:
require 'rubygems'
require 'zip/zipfilesystem'
Zip::ZipFile.open("Evelyn Attwood.docx.zip") {
|zipfile|
zipfile.dir.open("word")
puts zipfile.file.read("document.xml")
}
Simple, but I get an error:
ruby docxreader.rb
/Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:371:in
`stat': No such file or directory - word (Errno::ENOENT)
from
/Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:463:in
`foreach'
from
/Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:458:in
`entries'
from
/Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:430:in
`new'
from
/Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:434:in
`open'
from docxreader.rb:6
from /Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zip.rb:1382:in
`open'
from docxreader.rb:4
But there is certainly such a file. What am I doing wrong?
Much thanks,
Nathan
trying to open, go to directory "word" and read one of the files out.
Here is what I have so far:
require 'rubygems'
require 'zip/zipfilesystem'
Zip::ZipFile.open("Evelyn Attwood.docx.zip") {
|zipfile|
zipfile.dir.open("word")
puts zipfile.file.read("document.xml")
}
Simple, but I get an error:
ruby docxreader.rb
/Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:371:in
`stat': No such file or directory - word (Errno::ENOENT)
from
/Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:463:in
`foreach'
from
/Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:458:in
`entries'
from
/Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:430:in
`new'
from
/Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:434:in
`open'
from docxreader.rb:6
from /Library/Ruby/Gems/1.8/gems/rubyzip-0.9.1/lib/zip/zip.rb:1382:in
`open'
from docxreader.rb:4
But there is certainly such a file. What am I doing wrong?
Much thanks,
Nathan