Vít Kotačka Coverage matrix

Created by Vít Kotačka
"""This script provides a coverage matrix of contract and RQS requirements.

This script merges two CSV files exported from Redmine:
    * Contract requirements
    * RQS requirements

and provides a coverage matrix as an Excel file.

__author__ = "Vít Kotačka <>"

import pandas as pd

# pandas configuration
pd.set_option('display.expand_frame_repr', False)

# Inputs reading

csd = pd.read_csv('CSD.csv')
print('Contract requirements have been read.')

rqs = pd.read_csv('RQS.csv')
print('RQS requirements have been read.')

# CSD manipulation
csd[['CSD ID', 'Contract chapter']] = csd['Subject'].str.split(' > ', expand=True)
csd.drop(['Category', 'Subject', 'Assigned To', 'Target version', 'Release', 'Related issues'], axis=1, inplace=True)
csd = csd.rename(columns={'Status': 'CSD status'})
csd['numeric ID'] = csd['CSD ID'].str.replace('-', '').map(int)
print('CSD data have been transformed.')

# RQS manipulation
rqs['Related issues'] = rqs['Related issues'].str.split(' #', expand=True)[1].map(int)
rqs[['RQS ID', 'RQS description']] = rqs['Subject'].str.split(' ', expand=True, n=1)
rqs.drop(['Category', 'Subject', 'Assigned To', 'Target version', 'Release'], axis=1, inplace=True)
rqs = rqs.rename(columns={'#': 'Redmine ID', 'Status': 'RQS status'})
print('RQS data have been transformed.')

# Merge
matrix = csd.merge(rqs, left_on='#', right_on='Related issues', how='left')
matrix.drop('Related issues', axis=1, inplace=True)
matrix = matrix.rename(columns={'#': 'Related issues'})
matrix.set_index(['CSD ID', 'RQS ID'], inplace=True)
matrix = matrix.sort_values(by='numeric ID')
matrix.drop('numeric ID', axis=1, inplace=True)
cols = ['Contract chapter', 'CSD status', 'Redmine ID', 'RQS description', 'RQS status', 'Related issues']
matrix = matrix[cols]
print('Matrix has been created.')

# Output writing
print('Matrix has been writen to Excel.')

Comments (0)