1

我有一些 Primavera .xer 文件。我可以在记事本中打开这些文件,我看到有一些文本数据(它看起来像数据库数据)。

这些文件是否有任何 Python 解析器?

4

3 回答 3

1

The Primavera P6 XER format is indeed vulnerable to analysis by the CSV module. It's basically a tab-delimited back-up format for a relational database.

The first row is some meta-information about the file. Thereafter, each row begins with a code that tells what the rest of the row contains:

  • %T gives the name of a table.
  • %F gives the name of some fields in that table, all on one line.
  • %R is a record for the most recently-defined table.
  • %E is the end-of-file marker.

The rest depends entirely on how you want to use the data. For my part, I put the data directly into a (fresh, new) SQLITE database first and worry about applications later.

于 2018-12-19T15:23:11.847 回答
0

我知道有点晚了。但是,我一直在寻找类似的答案,但我找不到。因此,我开始开发一个名为 PyP6XER 的开源包。您可以在 github https://github.com/HassanEmam/PyP6Xer上点安装它或为开发做出贡献

请注意,该软件包仍处于早期阶段,并且没有很好的文档记录。

于 2021-03-03T21:26:43.003 回答
0

这不是一个理想的解决方案,但您可以尝试使用 MPXJ。MPXJ 本身是一个 Java 库,但假设您可以从 Python 代码启动一个单独的进程,您可以让它将 XER 文件转换为 JSON,这应该更容易使用(这是 MPXJ Ruby gem 使用的方法,它只是包装执行转换的 Java 代码,然后读取生成的 JSON)。您还应该发现 MPXJ 生成的 JSON 中的计划数据结构比 XER 文件的内容更易于使用,尽管您无法访问原始 XER 文件中的每个属性。

这个过程的红宝石版本可以在这里找到。总而言之,命令行将如下所示:

java -cp <classpath> net.sf.mpxj.sample.MpxjConvert your-file.xer your-file.json

您只需要设置 supply<classpath>来告诉 JVM MPXJ JAR 及其依赖项在哪里。

于 2018-10-15T09:07:09.023 回答