Search code examples
rimportodf

Elegant way to import table from ODF document into R


I started to fill some measurement data (that accumulated over a long time) into a table of an OpenOffice Writer document (saved as ODF), originally solely for documentation purposes.

Now I had the idea to process the data in the table with R, wondering how I could elegantly get the table data into R. The table is several pages long...


Solution

  • Considering the dependencies of docxtractr suggested by @davidski, I tried a different approach that worked:

    1. Mark the table in Writer (via Table->Select->Table), then Copy (^C).
    2. Open Calc, then paste (^V) the table. Mark the table (clicking in upper left corner), then copy it (^C).
    3. Use read.table(file="clipboard", header=TRUE, sep="\t") in R to get the table data.

    Note: Step 2 is necessary, because otherwise the resulting data frame is not correct.