A buyer receives a schedule for a Lahore office fit-out with two rows marked F07. One row names the reception and the other names a meeting room. Before anybody merges them, the team needs to know what F07 means. We'd give an LED Lighting schedule one identifier for each installed position and a separate field for the model that several positions can share.
Use the supplier's indoor lighting catalogue for model reconciliation when confirming the accepted product names. Give the script a local list of those approved names. A product may exist in the catalogue and still be the wrong choice for this job. The project list records what the designer and buyer actually approved.
Define what one row buys
Treat each row as one planned position. Two identical panels in one room get separate position IDs and the same model. If your current schedule uses one row per room with a quantity column, expand or adapt that representation before running a uniqueness check. Otherwise a repeated model number will look like an error when the buyer quite deliberately wants several of it.
Decide whether room names are free text or controlled values. For this check we only require a nonempty room. A later version could compare room names with a drawing register, but the buyer should understand the present limit. The word “Recepiton” would satisfy a nonempty field check even though a colleague might struggle to match it to a drawing.
Define the LED Lighting files
Save the signed working list as approved.txt with one model name per line. Save the schedule as schedule.csv with the header position,room,model. Use the CSV export option in the spreadsheet application. A correctly quoted room name can contain a comma without accidentally moving the model into another column.
Keep a dated copy of the input files together. If purchasing reports a problem after the designer has changed a room name, the reviewer needs the same input that produced the original message. Keeping the approved list beside the schedule also makes it clear which edition of the buying list was in force.
Paste this check into a local script
Save the following as check_schedule.py beside the two files and run python check_schedule.py from that directory. It uses the Python standard library. The two sample identifiers mentioned here are illustrative and should be replaced with real project references before the schedule is used for purchasing.
import csv
from pathlib import Path
def key(value):
return " ".join(value.split()).casefold()
approved = {}
for line in Path("approved.txt").read_text(encoding="utf-8-sig").splitlines():
name = line.strip()
if name:
if key(name) in approved and approved[key(name)] != name:
raise SystemExit(f"Ambiguous approved names for {name}")
approved[key(name)] = name
if not approved:
raise SystemExit("Approved list is empty")
seen = {}
issues = []
count = 0
with open("schedule.csv", encoding="utf-8-sig", newline="") as source:
rows = csv.DictReader(source, strict=True)
if rows.fieldnames != ["position", "room", "model"]:
raise SystemExit("Expected header: position,room,model")
for record, row in enumerate(rows, 1):
count += 1
if None in row or None in row.values():
issues.append(f"Record {record}: wrong column count")
continue
position = key(row["position"])
if not position:
issues.append(f"Record {record}: missing position")
elif position in seen:
issues.append(f"Record {record}: repeats position from {seen[position]}")
else:
seen[position] = record
if not row["room"].strip():
issues.append(f"Record {record}: missing room")
model = row["model"]
expected = approved.get(key(model))
if expected is None:
issues.append(f"Record {record}: unknown model {model!r}")
elif expected != model:
issues.append(f"Record {record}: use {expected!r}")
if not count:
issues.append("Schedule is empty")
for issue in issues:
print(issue)
if issues:
raise SystemExit(1)
print(f"Checked {count} positions")
The comparison ignores case and surrounding spaces for position IDs. Model names have a different rule. The script recognises case and extra whitespace when identifying a likely match, then asks for the spelling on the approved list. A genuinely different model remains an unresolved purchasing decision.
Try a mistake you can recognise
For a fictional trial, put Panel A in approved.txt. Enter P01,Reception,Panel A as the first data row. Enter p01,,panel a as the second. On that second row the script should report a repeated position, a missing room and the approved spelling of the model. These are three separate corrections even if they occur on a single line.
Then give the second position a unique ID, enter the correct room and copy the approved spelling. Run the same command again. The sample should now finish cleanly. Try an empty schedule as well. A report with no rows should never reach a buyer as a successful check simply because there were no duplicates to find.
Give each correction to the right person
A duplicate ID usually belongs with the person who owns the position drawing. They can tell whether two rooms really share a reference or whether someone copied a row without changing the ID. A missing room needs the same drawing context. Guessing a room from the model can send the correct product to the wrong floor.
Send an unknown model to the procurement lead with the original row intact. It may be an unapproved substitution or it may have a genuine new name. Add it to the accepted list only after the responsible person confirms the change. Quietly repairing an LED Lighting model name in the export makes the next export reproduce the same error.
Decide when the buyer can release quantities
A clean run means the supplied rows met these particular data rules. It doesn't establish photometric performance or even prove that every room on the drawing appears in the CSV. Ask the designer to reconcile the drawing count and sign off the release before procurement totals the approved models.
Keep the correction in the source schedule, export again and rerun the check on that export. This final step catches an easy mistake: fixing a local CSV while the next purchase request still comes from yesterday's spreadsheet. When a supplier reference needs clarification, send the original name and project-approved option to Hyundai LED so the buyer can document the answer against the affected position.
Top comments (0)