xer-reader


Namexer-reader JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/jjCode01/xer-reader
SummaryRead and parse a Primavera P6 xer file.
upload_time2023-11-23 02:01:19
maintainer
docs_urlNone
authorJesse Jones
requires_python>=3.10,<4.0
licenseGPL-3.0-only
keywords primavera p6 xer schedule scheduling planning project management project controls
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Xer-Reader

Read the contents of a Primavera P6 XER file using Python.  

Xer-Reader makes it easy to read, parse, and convert the data in a XER file to other formats.

*Refer to the [Oracle Documentation]( https://docs.oracle.com/cd/F25600_01/English/Mapping_and_Schema/xer_import_export_data_map_project/index.htm) for more information regarding how data is mapped to the XER format.  
Tested on XER files exported as versions 15.2 through 19.12.*  

## Install

**Windows**:

```bash
pip install xer-reader
```

**Linux/Mac**:

```bash
pip3 install xer-reader
```

## Usage  

Import the `XerReader` class from `xer_reader`.
```python
from xer_reader import XerReader
```

Create a new instance of an `XerReader` object by passing in the XER file as an argument. `XerReader` can accept the file path represented as a `str` or pathlib `Path` object, or a Binary file received as a response from requests, Flask, FastAPI, etc...

```python
file = r"/path/to/file.xer"
reader = XerReader(file)
```

### Attributes  

* `data` [str] - *The contents of the XER file as a string.*
* `export_date` [datetime] - *The date the XER file was exported.*
* `export_user` [str] - *The P6 user who export the XER file.*
* `export_version` [str] - *The P6 verison used to export the XER file.*
* `file_name` [str] - *The name of the file without the '.xer' extension.*

### Methods

**`check_errors()`** -> *list[str]*  
Checks the XER file for missing tables and orphan data, and returns the results as a list of errors.  

* Missing tables can occur when an entry in *Table 1* points to an entry in *Table 2* but *Table 2* does not exist at all.
* Orphan data occurs when an entry in *Table 1* points to an entry *Table 2* but the entry in *Table 2* does not exist.

**`delete_tables(*table_names: str)`** -> *str*  
Delete a variable number of tables (*table_names*) from the XER file data and returns a new string (*Does not modify `XerReader.data` attribute*).  

In the following example the tables associated with User Defined Fields are removed from the XER file contents and stored in a new variable `new_xer_data`, which can then be written to a new XER file:
```python
new_xer_data = reader.delete_tables("UDFTYPE", "UDFVALUE")

with open("New_XER.xer", "w", encoding=XerReader.CODEC) as new_xer_file:
    new_xer_file.write(new_xer_data)
```

**`get_table_names()`** -> *list[str]*  
Returns a list of table names included in the XER file.  

**`get_table_str(table_name: str)`** -> *str*  
Returns the tab seperated text for a specific table in the XER file.

**`has_table(table_name: str)`** -> *bool*  
Return True if table (`table_name`) if found in the XER file.

**`parse_tables()`** -> *dict[str, Table]*  
Returns a dictionary with the table name as the key and a `Table` object as the value.  

**`to_csv(file_directory: str | Path)`** -> *None*  
Generate a CSV file for each table in the XER file using 'tab' as the delimiter. CSV files will be created in the current working directory.   
Optional: Pass a string or Path object (`file_directory`) to speficy a folder to store the CSV files in.  

**`to_json(*tables: str)`** -> *str*  
Generate a json compliant string representation of the tables in the XER file.  
Optional: Pass in specific table names to include in the json string.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jjCode01/xer-reader",
    "name": "xer-reader",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "primavera,p6,xer,schedule,scheduling,planning,project management,project controls",
    "author": "Jesse Jones",
    "author_email": "code@seqmanagement.com",
    "download_url": "https://files.pythonhosted.org/packages/c6/72/4d018932458df40f835bd1257039a65465fcdfb51a658a2be2b8fa5ff299/xer_reader-0.1.5.tar.gz",
    "platform": null,
    "description": "# Xer-Reader\n\nRead the contents of a Primavera P6 XER file using Python.  \n\nXer-Reader makes it easy to read, parse, and convert the data in a XER file to other formats.\n\n*Refer to the [Oracle Documentation]( https://docs.oracle.com/cd/F25600_01/English/Mapping_and_Schema/xer_import_export_data_map_project/index.htm) for more information regarding how data is mapped to the XER format.  \nTested on XER files exported as versions 15.2 through 19.12.*  \n\n## Install\n\n**Windows**:\n\n```bash\npip install xer-reader\n```\n\n**Linux/Mac**:\n\n```bash\npip3 install xer-reader\n```\n\n## Usage  \n\nImport the `XerReader` class from `xer_reader`.\n```python\nfrom xer_reader import XerReader\n```\n\nCreate a new instance of an `XerReader` object by passing in the XER file as an argument. `XerReader` can accept the file path represented as a `str` or pathlib `Path` object, or a Binary file received as a response from requests, Flask, FastAPI, etc...\n\n```python\nfile = r\"/path/to/file.xer\"\nreader = XerReader(file)\n```\n\n### Attributes  \n\n* `data` [str] - *The contents of the XER file as a string.*\n* `export_date` [datetime] - *The date the XER file was exported.*\n* `export_user` [str] - *The P6 user who export the XER file.*\n* `export_version` [str] - *The P6 verison used to export the XER file.*\n* `file_name` [str] - *The name of the file without the '.xer' extension.*\n\n### Methods\n\n**`check_errors()`** -> *list[str]*  \nChecks the XER file for missing tables and orphan data, and returns the results as a list of errors.  \n\n* Missing tables can occur when an entry in *Table 1* points to an entry in *Table 2* but *Table 2* does not exist at all.\n* Orphan data occurs when an entry in *Table 1* points to an entry *Table 2* but the entry in *Table 2* does not exist.\n\n**`delete_tables(*table_names: str)`** -> *str*  \nDelete a variable number of tables (*table_names*) from the XER file data and returns a new string (*Does not modify `XerReader.data` attribute*).  \n\nIn the following example the tables associated with User Defined Fields are removed from the XER file contents and stored in a new variable `new_xer_data`, which can then be written to a new XER file:\n```python\nnew_xer_data = reader.delete_tables(\"UDFTYPE\", \"UDFVALUE\")\n\nwith open(\"New_XER.xer\", \"w\", encoding=XerReader.CODEC) as new_xer_file:\n    new_xer_file.write(new_xer_data)\n```\n\n**`get_table_names()`** -> *list[str]*  \nReturns a list of table names included in the XER file.  \n\n**`get_table_str(table_name: str)`** -> *str*  \nReturns the tab seperated text for a specific table in the XER file.\n\n**`has_table(table_name: str)`** -> *bool*  \nReturn True if table (`table_name`) if found in the XER file.\n\n**`parse_tables()`** -> *dict[str, Table]*  \nReturns a dictionary with the table name as the key and a `Table` object as the value.  \n\n**`to_csv(file_directory: str | Path)`** -> *None*  \nGenerate a CSV file for each table in the XER file using 'tab' as the delimiter. CSV files will be created in the current working directory.   \nOptional: Pass a string or Path object (`file_directory`) to speficy a folder to store the CSV files in.  \n\n**`to_json(*tables: str)`** -> *str*  \nGenerate a json compliant string representation of the tables in the XER file.  \nOptional: Pass in specific table names to include in the json string.\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-only",
    "summary": "Read and parse a Primavera P6 xer file.",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/jjCode01/xer-reader",
        "Repository": "https://github.com/jjCode01/xer-reader"
    },
    "split_keywords": [
        "primavera",
        "p6",
        "xer",
        "schedule",
        "scheduling",
        "planning",
        "project management",
        "project controls"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "174dcaebe7f80051eedb82fbd12f397c805713f3725673c650d25a7c25f3757b",
                "md5": "8fa1da90208093a97f736cc6a0a37a52",
                "sha256": "4125c7b6a5e6590aae534f426f98b47e9b9b94647e870b887ebae976278595e8"
            },
            "downloads": -1,
            "filename": "xer_reader-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8fa1da90208093a97f736cc6a0a37a52",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 20303,
            "upload_time": "2023-11-23T02:01:17",
            "upload_time_iso_8601": "2023-11-23T02:01:17.406035Z",
            "url": "https://files.pythonhosted.org/packages/17/4d/caebe7f80051eedb82fbd12f397c805713f3725673c650d25a7c25f3757b/xer_reader-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c6724d018932458df40f835bd1257039a65465fcdfb51a658a2be2b8fa5ff299",
                "md5": "5ff2a57ecfc208cbc90ce008815cd26c",
                "sha256": "8a2f4b59d7edb4e860fe1b9c136f49e1b91a3a5b57dcfe109c29e7f94a588c6b"
            },
            "downloads": -1,
            "filename": "xer_reader-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "5ff2a57ecfc208cbc90ce008815cd26c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 19824,
            "upload_time": "2023-11-23T02:01:19",
            "upload_time_iso_8601": "2023-11-23T02:01:19.335508Z",
            "url": "https://files.pythonhosted.org/packages/c6/72/4d018932458df40f835bd1257039a65465fcdfb51a658a2be2b8fa5ff299/xer_reader-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-23 02:01:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jjCode01",
    "github_project": "xer-reader",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "xer-reader"
}
        
Elapsed time: 0.15772s