[R] odfWeave: odt-file damaged

Jean lobry lobry at biomserv.univ-lyon1.fr
Wed Mar 17 22:31:35 CET 2010


Dear all,

I'm resurrecting this old post (about 6 monts old, reproduced thereafter)
because I have struggled against the same problem and found a solution
so that I found it was worth posting for the record.

The simple fix when you want to use odfWeave with 7-ZIP as a
compressing/decompressing utility under windows is to use the
'x' instead of the 'e' option so as to preserve the full hierachy
when decompressing. In the case of Udo's example that would be:

#######################################################################
#R code
library(odfWeave)
#odfWeave call
odfWeave("c:/temp/odfWeave-test.odt", "c:/temp/odfWeave-test-out.odt",
            control = odfWeaveControl(zipCmd = c("7z a -tzip $$file$$ .",
            "7z x -tzip $$file$$")))
#######################################################################

That's all!


In my case:

Well, no, I had extra problems because 7z wasn't in my path and because
there was a white space in the path, so that my solution was like
below (I'm typing from memory: double escape rule + embeding quotes,
do not take this as tested solution):

#######################################################################
odfWeave("in.odt", "out.odt",
            control = odfWeaveControl(zipCmd =
            c("\"c:\\bla bla\\7izp\\7z\"" a -tzip $$file$$ .",
            "\"c:\\bla bla\\7izp\\7z\"" x -tzip $$file$$")))
#######################################################################

Smells as a fortune("Hisaji"), isn't it ?

It would be so nice if zipping facilities were shipping with R so that
naive user won't have to cope with these problems under such an
hostile environment as windows. I'd like to fill a wish on R-dev
but I feel a little bit lonely using openOffice format (which is
mandatory for us for the long-term preservaion of data) while
still working under windows. Don't want to disturb R-dev for my
single case, but if you are in a similar situation please post
so that I can reconsider my position for posting a whish.

Many many thanks to Max for sharing odfWeave.

Best,

Jean

--
Pr. Jean R. Lobry (Dr. phil. hab.)
Head of Laboratoire de Police Scientifique de Lyon
Institut National de Police Scientifique
31 av. F. Roosevelt, F-69134 ECULLY CEDEX
Allo: +33 (0)4 72 86 89 60
e-mail: jean.lobry at interieur.gouv.fr


>  Hi,
>  I think, I can answer my own posting. I found out, that the directory
>  structure
>  of the ODT-file created by "odfWeave" causes the error message.
>
>  The file structure of the unzipped odt-file looks like this:
>
>  <DIR> Pictures
>         content_1-Boxplot.png
>  content.xml
>  current.xml
>  manifest.xml
>  meta.xml
>  mimetype
>  settings.xml
>  styles.xml
>  thumbnail.png
>
>
>  But it should look like this:
>
>  <DIR> META-INF
>         manifest.xml
>  <DIR> Thumbnails
>         thumbnail.png
>  <DIR> Pictures
>         content_1-Boxplot.png
>  meta.xml
>  mimetype
>  settings.xml
>  styles.xml
>  content.xml
>
>  Now I know. what causes the message "odt file damaged",
>  but I don´t know a solution. Does anyone do so?
>
>  Thanks, Udo
>
>
>
>
>  > Dear all,
>  > I am doing my first steps with odfWeave.
>  >
>  > After running the r code (see below), I am trying to open the ODF-document
>  > with open office, but I am getting the error message:
>  >
>  > "The file is damaged, but it can be repaired". If I confirm the 
>question and
>  > repair the file with open office, I can open it with the desired output,
>  > which seems to be fine.
>  >
>  > My system:
>  >     R Version 2.9.1
>  >     Open Office 3.0.1
>  >     7-Zip 4.65
>  >     Windows XP
>  >
>  > Using zip (http://www.info-zip.org/, zip232xN.zip) had the same result.
>  >
>  > What causes the error message?  Is the structure of the ODF document
>  > as it should be (for the structure please have a look at the bottom of
>  > this mail)?
>  >
>  > I'd greatly appreciate any help.
>  >
>  >
>  > Udo K o e n i g
>  >
>  > Clinic for Child and Adolescent Psychiatry
>  > Philipps University of Marburg, Germany
>  >
>  >
>  > #######################################################################
>  > #R code
>  > library(odfWeave)
>  >
>  > #odfWeave call
>  > odfWeave("c:/temp/odfWeave-test.odt", "c:/temp/odfWeave-test-out.odt",
>  >           control=odfWeaveControl(zipCmd = c("7z a -tzip $$file$$ .",
>  >           "7z e -tzip $$file$$")))
>  >
>  > #######################################################################
>  > # Contents of my Open office document
>  >
>  > <<Initiate, results = hide, echo= FALSE>>=
>  > #First steps with odfWeave
>  > attach(iris)
>  > @
>  >
>  > There are \Sexpr{length(iris[, 1])} observations.
>  >
>  > <<Table, echo=FALSE, results= xml>>=
>  > odfTable(iris[1:5,])
>  > @
>  >
>  > <<Table2, echo=FALSE, results= xml>>=
>  > tab <- round(apply(iris[, 1:4], 2, mean), 2)
>  > odfTable(tab, horizontal= TRUE)
>  > @
>  >
>  > <<Boxplot, echo=FALSE, fig=TRUE>>=
>  > boxplot(Sepal.Length~Species)
>  > @
>  >
>  > #######################################################################
>  > #Log
>  >
>  >> odfWeave("c:/temp/odfWeave-test.odt", "c:/temp/odfWeave-test-out.odt",
>  > +          control=odfWeaveControl(zipCmd = c("7z a -tzip $$file$$ .",
>  > +          "7z e -tzip $$file$$")))
>  >    Copying  c:/temp/odfWeave-test.odt
>  >    Setting wd to
>  > C:\DOCUME~1\Udo_2\LOCALS~1\Temp\Rtmp6QrXgk/odfWeave05190748330
>  >    Unzipping ODF file using 7z e -tzip "odfWeave-test.odt"
>  >
>  > 7-Zip 4.65  Copyright (c) 1999-2009 Igor Pavlov  2009-02-03
>  >
>  > Processing archive: odfWeave-test.odt
>  >
>  > Extracting  mimetype
>  > Extracting  Configurations2\statusbar
>  > Extracting  Configurations2\accelerator\current.xml
>  > Extracting  Configurations2\floater
>  > Extracting  Configurations2\popupmenu
>  > Extracting  Configurations2\progressbar
>  > Extracting  Configurations2\menubar
>  > Extracting  Configurations2\toolbar
>  > Extracting  Configurations2\images\Bitmaps
>  > Extracting  content.xml
>  > Extracting  styles.xml
>  > Extracting  meta.xml
>  > Extracting  Thumbnails\thumbnail.png
>  > Extracting  settings.xml
>  > Extracting  META-INF\manifest.xml
>  >
>  > Everything is Ok
>  >
>  > Folders: 7
>  > Files: 8
>  > Size:       28518
>  > Compressed: 8768
>  >
>  >    Removing  odfWeave-test.odt
>  >    Creating a Pictures directory
>  >
>  >    Pre-processing the contents
>  >    Sweaving  content.Rnw
>  >
>  >    Writing to file content_1.xml
>  >    Processing code chunks ...
>  >      1 : term hide(label=Initiate)
>  >      2 : term xml(label=Table)
>  >      3 : term xml(label=Table2)
>  >      4 : term verbatim(label=Boxplot)
>  >
>  >    'content_1.xml' has been Sweaved
>  >
>  >    Removing content.xml
>  >
>  >    Post-processing the contents
>  >    Removing content.Rnw
>  >    Removing styles.xml
>  >    Renaming styles_2.xml to styles.xml
>  >    Removing extra files
>  >
>  >    Packaging file using 7z a -tzip "odfWeave-test.odt" .
>  >
>  > 7-Zip 4.65  Copyright (c) 1999-2009 Igor Pavlov  2009-02-03
>  > Scanning
>  >
>  > Creating archive odfWeave-test.odt
>  >
>  > Compressing  content.xml
>  > Compressing  current.xml
>  > Compressing  manifest.xml
>  > Compressing  meta.xml
>  > Compressing  mimetype
>  > Compressing  Pictures\content_1-Boxplot.png
>  > Compressing  settings.xml
>  > Compressing  styles.xml
>  > Compressing  thumbnail.png
>  >
>  > Everything is Ok
>  >    Copying  odfWeave-test.odt
>  >    Resetting wd
>  >    Removing  C:\DOCUME~1\Udo_2\LOCALS~1\Temp\Rtmp6QrXgk/odfWeave05190748330
>  >
>  >    Done
>  >
>  > #######################################################################
>  > #Structure of the unzipped odf-document that produced the error message
>  >
>  > 05.07.2009  11:43    <DIR>          Bitmaps
>  > 05.07.2009  19:07            13.820 content.xml
>  > 05.07.2009  11:43                 0 current.xml
>  > 05.07.2009  11:43    <DIR>          floater
>  > 05.07.2009  11:43             1.889 manifest.xml
>  > 05.07.2009  11:43    <DIR>          menubar
>  > 05.07.2009  11:43               968 meta.xml
>  > 05.07.2009  11:43                39 mimetype
>  > 05.07.2009  22:18    <DIR>          Pictures
>  > 05.07.2009  11:43    <DIR>          popupmenu
>  > 05.07.2009  11:43    <DIR>          progressbar
>  > 05.07.2009  11:43             7.993 settings.xml
>  > 05.07.2009  11:43    <DIR>          statusbar
>  > 05.07.2009  19:07            13.281 styles.xml
>  > 05.07.2009  11:43             1.579 thumbnail.png
>  > 05.07.2009  11:43    <DIR>          toolbar

-- 
Pr. Jean R. Lobry (Dr. phil. hab.)
Head of Laboratoire de Police Scientifique de Lyon
Institut National de Police Scientifique
31 av. F. Roosevelt, F-69134 ECULLY CEDEX
Allo: +33 (0)4 72 86 89 60
e-mail: jean.lobry at interieur.gouv.fr



More information about the R-help mailing list