RM Mapping Automation
Overview
The RM Mapping automation converts the MDM dump into a standardized RM Mapping Excel file. It filters the required REL accounts, standardizes IDC and internal segment values, maps Segment Head and Segment Leader, rationalizes ISR and FTF Sales Manager names using reference workbooks, derives WW Segment, and writes a clean output workbook.
The automation replaces repetitive manual Excel operations with a repeatable Python process while retaining validation controls for mapping completeness and output quality.
Document Information
| Field | Value |
|---|---|
| Process Name | RM Mapping Automation |
| Segment | REL |
| Process Family | Lenovo India |
| Process Purpose | Automated preparation of RM Mapping from the MDM dump and reference mapping files. |
| Process User(s) | Wyzmindz Solutions Pvt Ltd |
Version Control
| Version | Prepared By | Date | Reviewed By | Approved By | Revision Details |
|---|---|---|---|---|---|
| V 1.0 | Wyzmindz | 07-10-2026 | Process Owner | Process Manager | SOP creation for automated RM Mapping |
| V 1.1 | Future automation / mapping revisions |
Distribution & Access List
| Designation | Read | Write | Approval |
|---|---|---|---|
| Analyst | Yes | No | No |
| Team Lead | Yes | Yes | No |
| Manager | Yes | Yes | Yes |
Table of Contents
- 1.1 Purpose
- 1.2 Scope
- 1.3 Business / Segment Overview
- 1.4 Responsibility and Authority
- 1.5 Escalation Matrix
- 1.6 RACI Matrix
- 1.7 Access Required
- 1.8 Overview of Tools
- 1.9 Legends and Mapping Rules
- 1.10 Dependencies
- 1.11 Schedule of Reporting
- 1.12 Process Flow Chart
- 1.13 Steps of Procedure
- 1.14 Code Logic and Automation Details
- 1.15 Output Overview
- 1.16 Validation Checklist
- 1.17 Exception Handling
- Appendix A – Quick Run Checklist
- Appendix B – Detailed Code Explanation, Usage Guide and Error Handling
RM Mapping
1.1 Purpose
The purpose of this SOP is to define the standard procedure for running the RM Mapping automation, preparing the MDM data, applying segment and sales ownership mappings, rationalizing representative names, and generating the final RM Mapping Excel output. The SOP also documents the Python logic so that the process can be operated, validated and maintained consistently.
1.2 Scope
- Geographic Scope: India.
- Business Segment: REL.
- Core Activity: Generate account-level RM Mapping containing DMU ID, Customer Name, WW Segment, IDC Segment, Internal Segment, Segment Head, Segment Leader, ISR Rep, FTF Sales Manager and Quarter.
- Source Data: MDM dump in XLSB format.
- Reference Data: REL Segment Head / Segment Leader mapping workbook and ISR / Region & Vertical mapping workbook.
- Output: Excel workbook, sheet "RM Mapping".
1.3 Business / Segment Overview
- The MDM dump contains customer/account information used to classify accounts into REL business segments.
- Only configured allowed REL segments are retained.
- Rows with blank, null or "-"
L3_dmu_crmidare excluded. - Segment Head and Segment Leader are assigned from the maintained segment mapping workbook.
- ISR and FTF Sales Manager names are standardized using exact matching first and fuzzy matching as a fallback.
- IDC Segment values are converted to standardized abbreviations for reporting.
1.4 Responsibility and Authority
| Role | Name |
|---|---|
| Analyst | Sharanya J |
| Process Owner | Navaneeth |
| Process Manager | Dayanand |
| Approval Authority | Vishwanath Mosale |
1.5 Escalation Matrix
WyzMindz Solutions Pvt Ltd India
| Level | Name | Designation | Email ID |
|---|---|---|---|
| 1 | Sushruth Vasista | Manager | sushruth.vasista@wyzmindz.com |
| 2 | Vishwanath Mosale | Director | Vishwanath.mosale@wyzmindz.com |
Lenovo India Pvt Ltd
| Level | Name | Designation | Email ID |
|---|---|---|---|
| 1 | T Renganathan | Sales Operations Head - Commercial | Trenganathan@lenovo.com |
| 2 | Saurabh Agarwal | Ops Director | asaurabh@lenovo.com |
1.6 RACI Matrix
WyzMindz Solutions Pvt Ltd India
| Report / Process | Responsible | Accountable | Consultation | Informed |
|---|---|---|---|---|
| RM Mapping | Sharanya J | Sharanya J | Navaneeth K | Lenovo Ind Pvt Ltd, Wyzmindz Solutions Pvt Ltd India |
1.7 Access Required
- MDM dump location access.
- Read/write access to the RM Mapping output folder.
- Access to the Segment Head / Segment Leader mapping workbook.
- Access to the ISR / Region & Vertical mapping workbook.
- Python environment with
pandas,pyxlsb,openpyxlandrapidfuzz. - MS Excel for final review.
1.8 Overview of Tools
| Level | Tool / Component | Purpose |
|---|---|---|
| 1 | Python | Runs the RM Mapping automation. |
| 2 | Pandas | Reads, filters, transforms and writes Excel data. |
| 3 | pyxlsb | Reads the XLSB MDM dump. |
| 4 | RapidFuzz | Performs fuzzy matching for ISR and FTF names. |
1.9 Legends and Mapping Rules
| Source Value / Rule | Output / Meaning |
|---|---|
| Education | EDU |
| Government | GOV |
| Large Business | LB |
| Medium Business | MB |
| Small Business | SB |
| Small Office | SO |
| Very Large Business | VLB |
| Public | PUB |
- WW Segment rule: GAB and GTC are mapped to
GAB; all other retained segments are mapped toKAB. - ISR and FTF matching normalizes case, leading/trailing spaces, repeated spaces and non-breaking spaces.
1.10 Dependencies
- MDM Dump XLSB file.
REL MAPPING - SEG LEADER.xlsx.- ISR / Region & Vertical mapping workbook.
- Configured file paths.
- Correct
QUARTERvalue.
1.11 Schedule of Reporting
The automation is executed according to the RM Mapping reporting cycle. The applicable quarter is controlled through the QUARTER parameter and must be updated before execution.
1.12 Process Flow Chart
START | Run Python RM Mapping automation
↓
1 | Read MDM XLSB dump
↓
2 | Identify last column as Internal Segment
↓
3 | Filter allowed REL segments + valid L3_dmu_crmid
↓
4 | Standardize IDC Segment
↓
5 | Load Segment Head / Segment Leader mapping
↓
6 | Map Segment Head and Segment Leader
↓
7 | Rationalize ISR: exact match → fuzzy match
↓
8 | Rationalize FTF: detect header → exact match → fuzzy match
↓
9 | Derive WW Segment + Public → PUB
↓
10 | Build final columns + Quarter
↓
11 | Write RM Mapping sheet
↓
12 | Validate output
↓
END | RM Mapping automation completed
1.13 Steps of Procedure
- Confirm the MDM dump and both reference mapping workbooks are available.
- Update
input_file,output_file,mapping_file,SM_ISR_mappingfileandQUARTERif locations or reporting period changed. - Read the MDM XLSB using pandas with the
pyxlsbengine. - Use the last MDM column as the segment column and trim whitespace.
- Retain only
EA OL,GAB,GTC,Private Edu,Public,SAandSLBD. - Exclude rows where
L3_dmu_crmidis null, blank or"-". - Standardize
idc_segmentusing the configured IDC mapping dictionary. - Normalize Internal Segment values and map Segment Head and Segment Leader.
- Load ISR mapping and perform exact normalized matching followed by RapidFuzz ratio matching at cutoff 80.
- Load Region & Vertical mapping. Detect the header row dynamically by locating
"Field Sales"and"Rationalised Field sales". - Apply the same exact-first / fuzzy-fallback logic to FTF Sales Manager using
Field Sales→Rationalised Field sales. - Derive WW Segment:
GAB/GTC→GAB; all other retained segments →KAB. - Set Internal Segment from the source segment and convert
Public→PUB. - Populate Quarter from
QUARTER. - Create the final output columns in the required order and write the RM Mapping sheet.
- Review validation checks before downstream use.
1.14 Code Logic and Automation Details
The automation follows a controlled read → filter → standardize → map → rationalize → derive → output sequence.
A. Input Configuration
input_file = r"...MDM Dump Sep - 08.xlsb"
output_file = r"...RM mapping automated.xlsx"
mapping_file = r"...REL MAPPING - SEG LEADER.xlsx"
SM_ISR_mappingfile = r"...Mapping-1787634732938.xlsx"
QUARTER = "Q2/2026"
These parameters allow the same script to be reused for a new MDM dump, mapping files and quarter.
B. MDM Loading and Filtering
df = pd.read_excel(input_file, sheet_name=0, engine="pyxlsb")
segment_col = df.columns[-1]
filtered_df = df[
segment_values.isin(allowed_segments)
& l3_values.notna()
& l3_values.ne("-")
& l3_values.ne("")
].copy()
The script reads the XLSB file, identifies the final column as the segment field, retains only allowed REL segments and excludes records without a valid L3 DMU CRM ID.
C. IDC Segment Standardization
idc_segment_mapping = {
"Education": "EDU",
"Government": "GOV",
"Large Business": "LB",
"Medium Business": "MB",
"Small Business": "SB",
"Small Office": "SO",
"Very Large Business": "VLB"
}
A dictionary lookup converts source IDC descriptions to standardized abbreviations.
D. Segment Head / Segment Leader Mapping
def normalize_segment(value):
if pd.isna(value):
return ""
return " ".join(str(value).strip().upper().split())
# Normalized Internal Segment → Segment Head / Segment Leader
Normalization makes mapping resilient to differences in capitalization, leading/trailing spaces and repeated spaces.
E. ISR Rationalization
# 1. Exact normalized match
if normalized_value in isr_lookup:
return isr_lookup[normalized_value]
# 2. Fuzzy fallback
match = process.extractOne(
normalized_value, isr_choices,
scorer=fuzz.ratio, score_cutoff=80
)
# 3. If no acceptable match, retain original value
Exact matching is preferred because it is deterministic. RapidFuzz is used only when an exact normalized key is unavailable. A cutoff of 80 is used to reduce weak matches.
F. FTF Header Auto-Detection
ftf_raw_df = pd.read_excel(
SM_ISR_mappingfile,
sheet_name="Region&Vertical",
header=None
)
header_row = next(
(i for i, row in ftf_raw_df.iterrows()
if "Field Sales" in row.astype(str).str.strip().values
and "Rationalised Field sales" in row.astype(str).str.strip().values),
None
)
if header_row is None:
raise ValueError("Could not find the FTF mapping headers.")
ftf_mapping_df = pd.read_excel(
SM_ISR_mappingfile,
sheet_name="Region&Vertical",
header=header_row
)
This is intentionally dynamic. If the mapping headers are in Excel row 2, pandas uses header=1; if they later move to Excel row 1, pandas uses header=0 automatically. No manual change is required.
G. Final Output Construction
The output is built with the following columns:
| DMU ID | Customer Name | WW Segment | IDC Segment | Internal Segment | Segment Head | Segment Leader | ISR_REP | FTF_Sales_Manager | Quarter |
|---|---|---|---|---|---|---|---|---|---|
The completed DataFrame is written to the RM Mapping sheet with index=False.
1.15 Output Overview
The generated workbook contains the standardized RM Mapping output with one account-level record per retained MDM record and the required segment and sales ownership fields.
1.16 Validation Checklist
- [ ] Output workbook is created successfully.
- [ ] RM Mapping sheet contains the expected columns.
- [ ] No blank /
"-"L3_dmu_crmidrecords are included. - [ ] Only configured allowed REL segments are present.
- [ ]
Publicis represented asPUB. - [ ] IDC Segment values follow the configured abbreviations.
- [ ] Segment Head and Segment Leader mappings are reviewed.
- [ ] ISR and FTF names are reviewed for unmatched or suspicious values.
- [ ] WW Segment follows
GAB/GTC→GAB; all others →KAB. - [ ] Quarter contains the configured
QUARTERvalue. - [ ] Record count is reviewed against the filtered MDM population.
1.17 Exception Handling
| Exception | Action |
|---|---|
| Mapping workbook missing | Verify configured path and file availability. |
| FTF headers not found | Verify Region&Vertical contains Field Sales and Rationalised Field sales. |
| Source columns changed | Stop and review the MDM structure before rerunning. |
| No fuzzy match ≥ 80 | Original name is retained; review the mapping workbook. |
| Output save failure | Close the workbook and verify folder/write permissions. |
Appendix A – Quick Run Checklist
- [ ] Confirm latest MDM XLSB dump.
- [ ] Confirm Segment Head / Segment Leader mapping workbook.
- [ ] Confirm ISR / Region & Vertical mapping workbook.
- [ ] Verify
QUARTERvalue. - [ ] Run the Python automation.
- [ ] Review record count and output columns.
- [ ] Review unmatched / suspicious ISR and FTF names.
- [ ] Review segment mappings and Quarter.
- [ ] Save / upload validated RM Mapping output.
Appendix B – Detailed Code Explanation, Usage Guide and Error Handling
B.1 Objective of the Python Automation
The Python script automates the repetitive Excel activities required to prepare the RM Mapping file. Instead of manually filtering rows, standardizing segments, looking up Segment Heads and Segment Leaders, and rationalizing ISR / FTF names, the script performs these operations in a controlled sequence.
The automation is designed to be rerun for a new MDM dump or quarter by changing the input parameters rather than rewriting the transformation logic.
B.2 Before Running the Code – Required Setup
The following must be available on the computer:
- Python installed and available from the Command Prompt / VS Code terminal.
- The MDM dump in XLSB format.
REL MAPPING - SEG LEADER.xlsx.- ISR / Region & Vertical mapping workbook.
- The Python script saved as a
.pyfile. - Write access to the output folder.
B.3 Install Required Python Libraries
Open the VS Code Terminal or Command Prompt and run the following commands:
python -m pip install pandas
python -m pip install pyxlsb
python -m pip install openpyxl
python -m pip install rapidfuzz
Using
python -m pipis recommended because it installs the package into the Python interpreter associated with thepythoncommand. This is especially useful when VS Code has more than one Python interpreter installed.
B.4 Import Section – What Each Library Does
import pandas as pd
import re
from rapidfuzz import process, fuzz
| Library / Import | Purpose in RM Mapping |
|---|---|
pandas |
Reads Excel files, filters records, creates lookup tables, transforms columns and writes the final workbook. |
re |
Python regular-expression library. Available for text-cleaning / pattern operations if required. |
rapidfuzz.process |
Finds the closest candidate during fuzzy matching. |
rapidfuzz.fuzz |
Provides the similarity score used by the fuzzy matching logic. |
pyxlsb |
Excel-reading engine used by pandas to read the XLSB MDM dump. |
B.5 File Path and Quarter Configuration
input_file = r"D:\REL\RM Mapping\Q2'2627\Sep\MDM Dump Sep - 08.xlsb"
output_file = r"C:\Users\W2625\Desktop\RM mapping automated.xlsx"
mapping_file = r"D:\REL\RM Mapping\RM Mapping_mapping files\REL MAPPING - SEG LEADER.xlsx"
SM_ISR_mappingfile = r"C:\Users\W2625\Desktop\Mapping-1787634732938.xlsx"
QUARTER = "Q2/2026"
These are the first values to check before every new run. The r before the path creates a raw Python string, which prevents Windows backslashes from being interpreted as escape characters.
When a new quarter or new input file is received, update the relevant path and the QUARTER value. Do not change the transformation logic unless the source structure or business rules have changed.
B.6 Reading the MDM XLSB Dump
df = pd.read_excel(
input_file,
sheet_name=0,
engine="pyxlsb"
)
The script reads the first worksheet of the MDM XLSB file. The pyxlsb engine is required because the source file is XLSB rather than a normal XLSX workbook.
If the MDM file changes from XLSB to XLSX, the reading method may need to change. Do not make this change without validating the new source format.
B.7 Identifying and Filtering the Segment
segment_col = df.columns[-1]
segment_values = df[segment_col].astype("string").str.strip()
l3_values = df["L3_dmu_crmid"].astype("string").str.strip()
filtered_df = df[
segment_values.isin(allowed_segments)
& l3_values.notna()
& l3_values.ne("-")
& l3_values.ne("")
].copy()
The automation treats the last MDM column as the Internal Segment / Segment field. It trims spaces, keeps only the configured allowed segments and removes records where L3_dmu_crmid is missing, blank or "-".
This is an important control because the final RM Mapping is intended to contain valid account records only.
B.8 Allowed Segment Logic
allowed_segments = {
"EA OL",
"GAB",
"GTC",
"Private Edu",
"Public",
"SA",
"SLBD"
}
Only these configured segments enter the final output. If a valid business segment is newly introduced, the allowed_segments list must be reviewed and updated before the automation is run for that business period.
B.9 IDC Segment Standardization
idc_segment_mapping = {
"Education": "EDU",
"Government": "GOV",
"Large Business": "LB",
"Medium Business": "MB",
"Small Business": "SB",
"Small Office": "SO",
"Very Large Business": "VLB"
}
filtered_df["IDC Segment"] = (
filtered_df["idc_segment"]
.astype("string")
.str.strip()
.replace(idc_segment_mapping)
)
The source IDC Segment is standardized to the abbreviations used in RM Mapping reporting. The replace operation converts only the configured source values; unexpected values should be reviewed rather than silently guessed.
B.10 Segment Head and Segment Leader Mapping
mapping_df = pd.read_excel(mapping_file)
def normalize_segment(value):
if pd.isna(value):
return ""
return " ".join(str(value).strip().upper().split())
mapping_df["Normalized Internal Segment"] = (
mapping_df["Internal Segment"].apply(normalize_segment)
)
segment_head_lookup = (
mapping_df.drop_duplicates("Normalized Internal Segment")
.set_index("Normalized Internal Segment")["Segment Head"]
.to_dict()
)
The mapping workbook is converted into a dictionary for fast lookup. Before lookup, Internal Segment values are normalized — for example, "Private Edu", "PRIVATE EDU" and "PRIVATE EDU" all become the same normalized key.
The Segment Leader lookup is built using the same normalized key. If an output Segment Head or Segment Leader is blank, check the reference mapping workbook first.
B.11 ISR Rationalization – Exact Match First
def normalize_isr(value):
if pd.isna(value):
return ""
return " ".join(
str(value).replace("\xa0", " ").strip().upper().split()
)
The ISR normalizer removes non-breaking spaces, trims leading/trailing spaces, converts text to uppercase and collapses repeated spaces.
if normalized_value in isr_lookup:
return isr_lookup[normalized_value]
The first matching method is an exact normalized match. This is preferred because the result is deterministic and does not depend on a similarity score.
B.12 ISR Rationalization – Fuzzy Match Fallback
match = process.extractOne(
normalized_value,
isr_choices,
scorer=fuzz.ratio,
score_cutoff=80
)
if match:
matched_isr = match[0]
return isr_lookup[matched_isr]
return original_value
If an exact match is not found, RapidFuzz compares the input with all normalized ISR mapping keys. The fuzz.ratio scorer calculates similarity and the score_cutoff of 80 prevents weak matches from being accepted.
If no acceptable fuzzy match is found, the original source value is retained. This makes the issue visible for review instead of replacing it with an unreliable guess.
B.13 FTF Sales Manager – Dynamic Header Detection
ftf_raw_df = pd.read_excel(
SM_ISR_mappingfile,
sheet_name="Region&Vertical",
header=None
)
header_row = next(
(
i for i, row in ftf_raw_df.iterrows()
if "Field Sales" in row.astype(str).str.strip().values
and "Rationalised Field sales" in row.astype(str).str.strip().values
),
None
)
The Region&Vertical sheet is initially read without a header. The script searches each row for both expected headers. This solves the issue where the mapping file may have headers on Excel row 1 today and Excel row 2 later.
| Excel Location of Headers | Pandas header Value Detected |
|---|---|
| Excel row 1 | header=0 |
| Excel row 2 | header=1 |
| Excel row 3 | header=2 |
The operator should not manually change
header=1toheader=0. The script detects the correct row automatically.
if header_row is None:
raise ValueError("Could not find the FTF mapping headers.")
ftf_mapping_df = pd.read_excel(
SM_ISR_mappingfile,
sheet_name="Region&Vertical",
header=header_row
)
ftf_mapping_df.columns = ftf_mapping_df.columns.str.strip()
If the expected headers are renamed, deleted or changed significantly, the script will stop with an error instead of silently producing incorrect FTF mappings.
B.14 FTF Exact and Fuzzy Matching
After the header is detected, the Field Sales column is normalized and mapped to Rationalised Field sales. The matching sequence is the same as ISR: exact normalized match first, RapidFuzz fuzzy match second, and original value retained if no acceptable match exists.
B.15 WW Segment Derivation
filtered_df[segment_col].apply(
lambda x: "GAB" if x in ["GAB", "GTC"] else "KAB"
)
GAB and GTC are grouped into WW Segment = GAB. All other retained segments are mapped to WW Segment = KAB.
B.16 Internal Segment Derivation
filtered_df[segment_col].replace({"Public": "PUB"})
The source segment is retained as Internal Segment, with Public standardized to PUB for the final RM Mapping.
B.17 Final Output Columns
| Output Column | Source / Logic |
|---|---|
| DMU ID | L3_dmu_crmid |
| Customer Name | L2_party_name |
| WW Segment | Derived from Internal Segment |
| IDC Segment | idc_segment standardized through dictionary |
| Internal Segment | Source segment; Public → PUB |
| Segment Head | Segment mapping workbook |
| Segment Leader | Segment mapping workbook |
| ISR_REP | Generalist_ISR_rep rationalized using ISR mapping |
| FTF_Sales_Manager | Generalist_FTF_rep rationalized using Region&Vertical |
| Quarter | QUARTER variable |
B.18 How to Run the Code – Step by Step
- Open the Python file in VS Code.
- Confirm that the selected VS Code Python interpreter is the same environment where
pandas,pyxlsb,openpyxlandrapidfuzzare installed. - Check all five configuration values:
input_file,output_file,mapping_file,SM_ISR_mappingfileandQUARTER. - Close the input and output Excel workbooks if they are open.
- Open the VS Code Terminal.
- Run:
python your_script_name.py - Wait for the success message and record count.
- Open the generated
RM mapping automated.xlsxfile. - Check the RM Mapping sheet using the validation checklist.
- Review any unmatched ISR / FTF names before downstream use.
B.19 Expected Successful Run
RM Mapping automation completed successfully!
Total records: <number>
Output saved to: C:\Users\W2625\Desktop\RM mapping automated.xlsx
The exact record count will change with the MDM dump and quarter. The important checks are that the script completes without a traceback, an output file is created, and the output record count is reasonable compared with the filtered MDM population.
B.20 Common Errors and How to Fix Them
| Possible Error / Symptom | Action |
|---|---|
ModuleNotFoundError: No module named 'pandas' |
Run: python -m pip install pandas. Then restart VS Code if required. |
ModuleNotFoundError: No module named 'pyxlsb' |
Run: python -m pip install pyxlsb. |
ModuleNotFoundError: No module named 'rapidfuzz' |
Run: python -m pip install rapidfuzz. Confirm VS Code is using the same Python interpreter. |
Import 'rapidfuzz' could not be resolved |
Usually a VS Code interpreter/environment issue. Select the correct Python interpreter and install RapidFuzz. |
FileNotFoundError |
Check the exact file path, filename, drive and extension in input_file / mapping_file / SM_ISR_mappingfile. |
PermissionError: [Errno 13] Permission denied |
Close the output Excel file if it is open. Check that the user has write permission to the output folder. |
ValueError: Worksheet named 'ISR' not found |
Open the mapping workbook and verify the sheet is named exactly ISR. |
ValueError: Worksheet named 'Region&Vertical' not found |
Verify the sheet name and spelling in the mapping workbook. |
KeyError: 'L3_dmu_crmid' |
The MDM dump does not contain the expected column name. Check headers for spelling, spaces or a source-format change. |
KeyError: 'idc_segment' |
The IDC Segment source column is missing or renamed. Verify the MDM dump structure. |
KeyError: 'Generalist_ISR_rep' |
The expected ISR source column is missing or renamed. |
KeyError: 'Generalist_FTF_rep' |
The expected FTF source column is missing or renamed. |
KeyError: 'Field Sales' / 'Rationalised Field sales' |
The Region&Vertical headers were changed or are not present. Verify the mapping workbook. |
Could not find the FTF mapping headers |
The dynamic header detector could not find both expected headers. Check header names and sheet content. |
| No Segment Head / Segment Leader returned | Check whether the normalized Internal Segment exists in the mapping workbook. |
| ISR / FTF name remains unchanged | No exact match and no fuzzy match at score 80 or above was found. Review the mapping file. |
| Excel output has 0 records | Check allowed_segments and L3_dmu_crmid filtering. MDM dump may contain different segment names or missing IDs. |
| pyxlsb engine error | Verify the source is a valid XLSB workbook and that pyxlsb is installed in the active Python environment. |
B.21 Troubleshooting Sequence
When an error occurs, do not immediately change the transformation logic. Follow this order:
- Read the last lines of the traceback; they usually identify the failed line and missing item.
- Check the file path and file name.
- Check the worksheet name.
- Check the source column names.
- Check the Python interpreter selected in VS Code.
- Check whether the required package is installed in that interpreter.
- Open the reference workbook and verify the expected mapping headers.
- Only after these checks, review the business logic or mapping rules.
B.22 How to Handle a Future Change in Header Row
For the Region&Vertical sheet, do not change the code manually when the header moves between Excel row 1 and row 2. The dynamic header detection is specifically designed for this scenario.
For other sheets, if a header row changes and the code currently uses a fixed header parameter, first inspect the workbook structure. A fixed header=1 means Excel row 2, while header=0 means Excel row 1 and header=2 means Excel row 3.
B.23 Safe Maintenance Rules
- Do not overwrite the reference mapping workbook without keeping an approved copy.
- Do not lower the fuzzy-match cutoff below 80 without business approval and testing.
- Do not add a new allowed segment without confirming the required Segment Head / Segment Leader mapping.
- Do not manually overwrite automated output values without recording the reason.
- After any code change, test the automation against a known MDM sample and compare the output with an approved RM Mapping file.
- When changing file paths for a new quarter, change only the configuration values unless the source structure has changed.
B.24 Operator Quick Reference
| Task | What to Do |
|---|---|
| New MDM dump | Change input_file. |
| New output location | Change output_file. |
| New Segment mapping workbook | Change mapping_file. |
| New ISR / FTF mapping workbook | Change SM_ISR_mappingfile. |
| New quarter | Change QUARTER. |
| Headers moved in Region&Vertical | No code change; dynamic detection handles row position. |
| New Python machine | Install required packages and verify interpreter. |
| Mapping name not rationalized | Check exact spelling first, then review fuzzy-match result / mapping file. |
| Output validation | Use Section 1.16 checklist. |
B.25 Important Control Point
The automation is intended to standardize the repeatable data preparation process. It does not replace business validation of new or ambiguous mappings. Any unexpected segment, missing mapping or suspicious fuzzy match should be reviewed before the RM Mapping output is used downstream.