【问题标题】:trying to determine an approach to my programming issue试图确定解决我的编程问题的方法
【发布时间】:2012-08-20 15:16:20
【问题描述】:

我遇到了这个问题。我有大约 10k 个包含一堆性能数据的 xml 文件。我需要parce,然后将它们导入excel,这样我就可以从中生成一个图表。

我正在尝试确定解决此问题的最佳方法。我无法直接导入,因为 excel 无法将其识别为有效的 xml 格式。 (excel给了我无法识别的架构或某些东西)

文件格式是这样的:(我只包含了有用的信息。) 文件名如下所示:YYDDMM.startOfPMPeriod_endOfPMPeriod 并在文件中:

<time stamp>
<PM category1>
<PM category2>
<PM category3>
...

<sub system 1>
<result>1</result>
<result>2.0</result>
...

<sub system 2>
<result>0.221</result>
<result>2.0</result>
...

<sub system n>
<result>1</result>
<result>2.0</result>

这些文件大约有 10k 个。每个文件大约有 6k 行。 :)

我不确定如何处理这个问题。我明白了它的基本逻辑:

while (we got more files to read) 
    read a file
    parse PM category and timestamp
          while (not end of file)
               reading in results data and the subsystems
    //store it in an array of some sort, but I am not sure about the structure of it
//once we are done with our files
pass the array to excel, (somehow, maybe as a CSV?)

你们认为解决这个问题的最佳方法是什么?我的编程能力有限。我熟悉 java、c++ 和 bash 脚本。 3维数组超出了我的范围。我在二维方面遇到了足够的麻烦。 :) 我最复杂的任务是用 java 制作一个多线程的银行应用程序。

戴维

更新:它适用于 excel 2003 excel表格应该是这样的:我不能附上图片,所以你必须这样做:

                      timestamp 1   timestamp2  timestamp 3
subsystem 1 pm cat 1
            pm cat 2
            pm cat 3

subsystem 2 pm cat 1
            pm cat 2
            pm cat 3

【问题讨论】:

  • 操作,我真傻。 Excel 2003。

标签: xml parsing architecture excel-2003


【解决方案1】:

我建议您首先使用VSTO 插入一条数据。插入单行后,您可以重新使用所学的内容来插入多行。

XML 到 NxN 数组是攻击 XML 解析的一种过于复杂的手段。通过XPATHLINQ to XML 可以有效地完成XML 解析。如果您没有使用 LINQ 的经验,也许 XPATH 是一个更好的开始。

首先弄清楚您希望行在 excel 中如何显示,然后相应地提取 XML。这将避免 N x N 数组,并为您提供生成已知输出的目标。

【讨论】:

  • 微软主互操作程序集中是否包含 VSTO?因为这就是链接给我的。
  • 看来VSTO需要visual studio,visual basic 2010 express就够了吗?
  • 大家好,我已将导入问题修复为 excel。 excel 2003 可以根据您的xml文件创建映射,允许您导入一个xml文件。但是多次导入仍然失败。
  • 好消息,原来我的一个同事为此编写了一个宏,除了它的那种错误,至少我不必从头开始。感谢 P.Brian.Mackey 的帮助。
猜你喜欢
  • 1970-01-01
  • 2022-01-25
  • 1970-01-01
  • 1970-01-01
  • 2020-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多