简体   繁体   中英

How to read/convert Excel XML files to R/CSV?

I have few hundred XML files. They are probably generated from/to Excel. I would like to read it to R or convert to CSV. Headers of all files look like this:

<?xml version="1.0" encoding="UTF-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">

I can always write parser, but would like to avoid doing it. I don't have Excel

There is a chapter in the "R Data Import/Export" manual (one of the free manuals that installs with R) on reading data from Excel spreadsheets. If the above XML file is a saved spreadsheet from recent versions of Excel then some of those tools should read them easily. I would probably start with either the RODBC package or the XLConnect package.

If those don't work then the XML package should at least make writing the parser much easier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM