Parse a P6 .xer file to a Python dictionary object.
Project description
xerparser
A simple Python package that reads a P6 .xer file and converts it into a Python dictionary object.
Disclaimer: this package is only usefull if you are already familiar with the mapping and schemas used by P6 during the export process.
Refer to the Oracle Documentation for more information regarding how data is mapped to the XER format.
Install
Windows: pip install xerparser
Linux/Mac: pip3 install xerparser
Usage
xer_to_dict(file: str | bytes) -> dict
Import the xer_to_dict function from xerparser and pass a .xer file as an argument.
from xerparser import xer_to_dict
file = r"/path/to/file.xer"
xer = xer_to_dict(file)
The xer_to_dict function accepts .xer file passed as type str or type bytes.
The file and table data will be parsed and returned as a Python dictionary object contining the file and table data from the .xer.
Keys / Attributes
["version"] -> Version of P6 the .xer file was exported as.
["export_date"] -> Date the .xer file was exported from P6 (datetime object).
["errors"] -> A list of potential errors in the .xer file based on common issues encountered when analyzing .xer files:
-
Minimum required tables - an error is recorded if one of the following tables is missing:
- CALENDAR
- PROJECT
- PROJWBS
- TASK
- TASKPRED
-
Required table pairs - an error is recorded if Table 1 is included but not Table 2:
P6 Table 1 P6 Table 2 Notes TASKFIN FINDATES Financial Period Data for Task TRSRCFIN FINDATES Financial Period Data for Task Resource TASKRSRC RSRC Resource Data TASKMEMO MEMOTYPE Notebook Data ACTVCODE ACTVTYPE Activity Code Data TASKACTV ACTVCODE Activity Code Data -
Non-existent calendars assigned to activities.
["tables"]: Dictionay of each table included in the .xer file.
Examples: PROJECT, PROJWBS, CALENDAR, TASK, TASKPRED, etc... See Oracle Documentation for mapping and schema of P6 database tables.
The table name (e.g TASK) is the key, and the value is a list of the table entries, which can be accessed the same as any Python dictionary object:
xer["tables"]["TASK"]
# or
xer["tables"].get("TASK")
Each table entry is a dictionary object where the key is the field name (e.g. task_id, task_code, and task_name) from the table schema.
for task in xer["tables"].get["TASK", []]:
print(task["task_code"], task["task_name"]) # -> A1000 Install Widget
Example Code
from xerparser import xer_to_dict
xer = xer_to_dict("*path to file.xer*")
xer["version"] # -> 15.2
xer["export_date"] # -> datetime.datetime(2022, 11, 30, 0, 0)
xer["errors"] # -> []
xer["tables"].get("TASK") # -> [{"task_id": 12345, ...}, {"task_id": 12346,...}]
len(xer["tables"].get("TASK",[])) # -> 950
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for xerparser-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e074b6f747bfdc66b07aebbdd3a931ccbc3edb3823197074f5a6688277a4a67 |
|
MD5 | 8d832c6349f220538905f289f9f76641 |
|
BLAKE2b-256 | 00142b22ab989602d2063d92dc35ebf51f394ca18834691c857fa0aef9be698e |