Skip to main content

PyP6: Python for Primavera P6

PyPI version License: MIT

PyP6 is a command-line toolkit designed to streamline and automate workflows for Oracle Primavera P6 by directly interacting with its SQLite database. It allows project managers, planners, and developers to programmatically add and manage project data like OBS, WBS, Activities, and Relationships using simple CSV files.

This package is ideal for:

  • Bulk-loading data into new projects.
  • Automating the creation of standardized project structures.
  • Integrating P6 with other data sources and systems.
  • Reducing manual data entry and minimizing errors.

Features

  • Modular Scripts: Separate, focused command-line tools for each data type.
  • Simple Configuration: A one-time setup command creates an easy-to-edit configuration file.
  • CSV-Driven: Uses standard, easy-to-create CSV files as the data source.
  • Intelligent Linking: Automatically handles relationships between new and existing activities.
  • Robust and Safe: Uses database transactions to ensure that imports are all-or-nothing, preventing partial, corrupted data.

Author


Installation

PyP6 requires Python 3.8 or higher. You can install it directly from PyPI using pip.

pip install pyp6

Getting Started: A 3-Step Guide

Using PyP6 is a simple, three-step process.

Step 1: Initialize Your Configuration (One-Time Setup)

Before using any of the import scripts, you must first initialize PyP6. Open your terminal or command prompt and run:

pyp6-init

This command will create a new configuration file at a standard location in your user's home directory (e.g., C:\Users\YourName\.pyp6\config.json on Windows or ~/.pyp6/config.json on macOS/Linux).

The output will look like this:

No configuration file found. Creating a new template at: C:\Users\YourName\.pyp6\config.json

SUCCESS: A new configuration file has been created.

IMPORTANT: You must now edit this file with your actual paths.
  -> Edit file: C:\Users\YourName\.pyp6\config.json

File contents:
-------------
{
    "target_project_id": "UTHP",
    "hours_per_day": 8.0,
    "user_name": "PyP6_Script",
    "database_path": "C:\\path\\to\\your\\database.db",
    "data_folder_path": "C:\\path\\to\\your\\Data"
}
-------------

You must now open this config.json file and edit the placeholder paths:

  1. database_path: Change this to the full path of your P6 SQLite (.db) file.
  2. data_folder_path: Change this to the full path of the folder where you will store your CSV input files.
  3. You can also change the default target_project_id, hours_per_day, and user_name to match your environment.

Step 2: Prepare Your CSV Data Files

In the data folder you specified in config.json, create the CSV files for the data you wish to import. The structure for each file is detailed below.

Step 3: Run the Import Scripts

Once your configuration is set and your CSV files are ready, you can run the import scripts from your terminal. The order matters for hierarchical data.

A typical workflow would be:

# 1. Import the Organizational Breakdown Structure
pyp6-obs

# 2. Import the Work Breakdown Structure
pyp6-wbs

# 3. Import Activities and their Relationships
pyp6-activities

Important: After importing activities or relationships, you must open the project in Primavera P6 and reschedule it (press F9) for the changes to be fully calculated and reflected in the Gantt chart.


CSV File Formats

All CSV files should be placed in the data_folder_path defined in your config.json.

1. OBS (obs.csv)

Used by the pyp6-obs command. Defines the organizational hierarchy.

OBS_Name Parent_OBS_Name
UTHP
PMC UTHP
Contractor UTHP
Engineering PMC
  • OBS_Name: The name of the OBS element.
  • Parent_OBS_Name: The name of the parent OBS element. Leave blank for top-level elements.

2. WBS (wbs.csv)

Used by the pyp6-wbs command. Defines the project's work breakdown structure.

WBS Short Name WBS Name Parent WBS Name
UTHP.1 Mobilization
UTHP.3 Construction Works
UTHP.3.1 Headrace Tunnel & Surge Shaft Construction Works
  • WBS Short Name: The unique code or identifier for the WBS element.
  • WBS Name: The descriptive name of the WBS element.
  • Parent WBS Name: The name of the parent WBS element. Leave blank for elements directly under the project root. Parent rows must appear before their children in the CSV.

3. Activities (activities.csv)

Used by the pyp6-activities command. Defines activities, their placement in the WBS, and their logical relationships.

Activity_ID Activity_Name Duration_Days WBS_Name Predecessors
A1000 Site Mobilization 20 Mobilization
A1010 Foundation Works 30 Construction Works A1000
A1020 Start Steel Erection 15 Construction Works A1010[SS+5d]
A1030 Final Inspection 5 Mobilization A1010[FS], A1020[FF-2d]
  • Activity_ID: The unique code for the activity.
  • Activity_Name: The descriptive name.
  • Duration_Days: The duration in days (will be converted to hours based on your config).
  • WBS_Name: The name of the WBS element to place this activity under. Leave blank to place it under the project root.
  • Predecessors: A comma-separated list of predecessor activities. The format is ActivityID[Type+Lag].
    • Type: FS, SS, FF, SF. Defaults to FS if omitted.
    • Lag: A number followed by d (days) or h (hours). E.g., +5d, -10h. Defaults to 0 if omitted.

4. Roles (roles.csv)

Used by the pyp6-roles command. Defines the global roles hierarchy.

Role_Name Role_Short_Name Parent_Role_Name
Engineering ENG
Civil Engineer CIVIL Engineering
Project Mgmt PM

Contributing

Contributions are welcome! If you have ideas for new features, improvements, or have found a bug, please feel free to open an issue or submit a pull request on the project's GitHub repository.

https://github.com/SanjeevBashyal/PyP6

Release files for pyp6 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyp6 0.1.5
File Size Uploaded
pyp6-0.1.5.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyp6 0.1.5
File Interpreter ABI Platform
pyp6-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 35.2 kB

Release files / pyp6-0.1.5.tar.gz

Download URL pyp6-0.1.5.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c19b45c189c0be30538f15280f6cbcf9eaee7412d0786c2d6013fe8e38f68ac3
BLAKE2b-256 checksum
How to use checksums
716c019470ef4b6fc86eaea04fc6b0200d07e01e14964be295beda132f509655
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.5

Release files / pyp6-0.1.5-py3-none-any.whl

Download URL pyp6-0.1.5-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db9022ccbb3b76551a50942add93666c72bb3d91175b3bb7ccdb1741be96b616
BLAKE2b-256 checksum
How to use checksums
90fc9366ad55163672f00a3ac107a49033fa4ecbfdf334b5e6d313267a71e913
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page