Two order exports contained the same fields in different column orders. The first also had a blank customer name. The second had a row with an extra field. I used those four synthetic rows to test a small Python script that separates usable rows from rows a person needs to review.

Input

The east export puts the order ID first.

Order,Name,Region 001,"Lee, Jordan",East 002, ,East 

The west export puts it last.

Region,Name,Order West,Mina,003 West,Sam,004,extra 

Resolve the headers once per file

The mapping is Order → order_id, Name → customer, and Region → region. Resolve the position of each source header independently for each file. The destination order comes from the mapping.

positions = [columns.index(name) for name in mapping] values = [row[position].strip() for position in positions] 

This is the extraction step, after checking that the headers exist and that the row has the expected number of fields. Python’s CSV reader handles the quoted comma in "Lee, Jordan". The script leaves IDs as strings, so 001 keeps its leading zeros.

Check both outputs

The sample run produced 2 accepted rows and 2 rejected rows. The consolidated CSV contained these values.

order_id,customer,region 001,"Lee, Jordan",East 003,Mina,West 

The second output pointed back to the exact records that needed review.

source,line,reason east.csv,3,Missing values: customer west.csv,3,Expected 3 columns 

Missing input headers stop the batch before output is written. A blank mapped value or a wrong field count rejects the affected row. That distinction lets an operator correct an isolated row without mistaking a broken export schema for a successful import. The script also refuses to overwrite an existing output directory.

Four CLI tests covered column reordering and text IDs, row validation, missing headers, and overwrite protection. The sample reads UTF-8 CSVs and holds the batch in memory, which suits small local exports.