A small python tool to manipulate Work Item Qury exports to make them re-importable into another Azure DevOps Organization.
Find a file
2025-05-22 12:00:54 +02:00
README.md new: Script to transform Azure DevOps export csv to an importable csv for workitems. 2025-05-22 12:00:54 +02:00
reorder_requirements.py new: Script to transform Azure DevOps export csv to an importable csv for workitems. 2025-05-22 12:00:54 +02:00
requirements.pip new: Script to transform Azure DevOps export csv to an importable csv for workitems. 2025-05-22 12:00:54 +02:00

Python Azure DevOps Work Item CSV

Run Example

# 1  Create and activate an isolated Python environment
python3 -m venv .venv
source .venv/bin/activate

# 2  Install runtime dependencies
python -m pip install --upgrade pip
python -m pip install -r requirements.pip

# 3  Convert the CSV
python reorder_requirements.py "input.csv" "output.csv"

python reorder_requirements.py -v "/Users/jj/Downloads/input.csv" "/Users/jj/Downloads/output.csv"

Execution Logic Summary

  1. build_level_map walks up the Parent chain to assign every row its depth (1, 2, 3, …).
  2. depth_first_order produces a depth-first sequence of IDs so that each parent is immediately followed by its children (and grandchildren).
  3. restructure creates the empty ID column plus the mutually-exclusive Title 1 3 columns and appends every other original column (except the old ID, Parent, and Title).
  4. The script writes the new CSV; nothing is printed except a final “Wrote … rows” confirmation.

Youll get a file whose first four columns are:

ID Title 1 Title 2 Title 3 …other original fields…

where:

  • Top-level items fill Title 1.
  • Second-level items fill Title 2.
  • Third-level (and deeper) items fill Title 3.

All hierarchy constraints you specified are enforced automatically. Feel free to adapt the column names or add CLI switches if you ever need variations (e.g., different max depth).