简体   繁体   English

如何将Excel XML文件读取/转换为R / CSV?

[英]How to read/convert Excel XML files to R/CSV?

I have few hundred XML files. 我有几百个XML文件。 They are probably generated from/to Excel. 它们可能是从Excel生成的。 I would like to read it to R or convert to CSV. 我想将其读取为R或转换为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 我没有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. “ R Data Import / Export”手册(R附带的免费手册之一)中有一章是关于从Excel电子表格中读取数据的。 If the above XML file is a saved spreadsheet from recent versions of Excel then some of those tools should read them easily. 如果上述XML文件是从Excel的最新版本保存的电子表格,则其中一些工具应该可以轻松阅读它们。 I would probably start with either the RODBC package or the XLConnect package. 我可能会从RODBC包或XLConnect包开始。

If those don't work then the XML package should at least make writing the parser much easier. 如果这些都不起作用,那么XML包至少应该使编写解析器更加容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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