Skip to main content

A Python package for interacting with and automating workflows for Primavera P6 SQLite databases.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyp6-0.1.5.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyp6-0.1.5-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file pyp6-0.1.5.tar.gz.

File metadata

  • Download URL: pyp6-0.1.5.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for pyp6-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c19b45c189c0be30538f15280f6cbcf9eaee7412d0786c2d6013fe8e38f68ac3
MD5 9278f27a28e45ac615d6b188c3abde25
BLAKE2b-256 716c019470ef4b6fc86eaea04fc6b0200d07e01e14964be295beda132f509655

See more details on using hashes here.

File details

Details for the file pyp6-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: pyp6-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for pyp6-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 db9022ccbb3b76551a50942add93666c72bb3d91175b3bb7ccdb1741be96b616
MD5 272a6b705b09d185cc7387220acf0fc2
BLAKE2b-256 90fc9366ad55163672f00a3ac107a49033fa4ecbfdf334b5e6d313267a71e913

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page