diff options
| -rw-r--r-- | R/xmltotab.R | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/R/xmltotab.R b/R/xmltotab.R index 9bec6d0b..675132a7 100644 --- a/R/xmltotab.R +++ b/R/xmltotab.R @@ -1,13 +1,10 @@ ## example to convert an Excel xml file to tab delimited - -input <- xmlToList("grid1_1cz1rlvt.xml") -for(row in input$Worksheet$Table){ - line <- c() - for(cell in row){ - if("Data" %in% names(cell)){ - line <- c(line, cell$Data$text) - } - } - cat(paste(line, collapse="\t"), "\n", file="output.csv", append=TRUE) +library(XML) +input <- xmlParse("/home/share/guillaume/grid1_1cz1rlvt.xml") +top <- xmlRoot(input) +table <- top[["Worksheet"]][["Table"]] +for(row in 1:xmlSize(table)){ + cat(paste(xmlSApply(table[[row]], xmlValue), collapse="\t"), "\n", file="output.csv", append=TRUE) } + |
