CSV DictReader Row Width: Separate Empty, Missing and Extra Fields in a Drone Register
Use an offline Python example to distinguish empty CSV cells, absent fields and surplus columns before reviewing a drone handoff register.

Name the problem before importing a register
A drone mapping handoff can include a small CSV register alongside imagery, models and processing notes. A reviewer may expect three columns and see apparently blank values in several rows. Those blanks deserve a structural check before anyone starts filling them. An explicitly empty cell, an absent trailing field and an additional unlabelled value represent different observations. Treating all three as the same missing note can hide a changed export layout. This tutorial builds an invented register in memory, records those distinctions and leaves every source value untouched. It describes a document review technique, rather than an actual NiVO project or product export.
Start with a written expectation: code, note and status, in that exact order. The names are deliberately ordinary; they carry no coordinate reference, aircraft identity or acceptance meaning. Keep a copy of the supplied file outside the experiment and record the chosen delimiter and encoding in a review note. A successful structural check will only establish that this small profile can account for its fields. It will not establish that a code identifies the right flight, that a status is authorized, or that a note is accurate. Those questions need the handoff agreement and the people responsible for the register.
Read what DictReader does with uneven rows
Python documents that DictReader maps fields to dictionary keys, normally taking names from the first row when names are not supplied explicitly. For a nonblank row with too few fields, restval supplies the missing entries. For excess fields, restkey names a dictionary entry containing their list. Both defaults are None. Here the reader uses the explicit reserved key __extra__ and leaves restval as None. An ordinary empty CSV field remains an empty string. This makes three states observable without changing the original records or guessing the intended content.
The reserved key belongs to this local review convention, not to the CSV format. Rejecting an unexpected header prevents a real column from colliding with it. Requiring the exact expected header also rejects repeated or reordered labels in this exercise. That narrow choice is useful when demonstrating row width: it keeps a header change from being silently mixed with a data row issue. A different register may legitimately have different labels or order. Update its documented contract first, rather than weakening a check merely because a particular file happens to fail.

Product context only; this photograph does not depict the constructed examples in this article.
Run a bounded offline classification
The following standard library example reads an in-memory string with newline handling supplied to StringIO. It imposes a small local size limit and requires the agreed header. The limit is a demonstration boundary, not a vendor specification or a universal CSV capacity. Each emitted position is an ordinal data record in this example, not a physical line number or a permanent identifier. Quoted line breaks can make those concepts diverge in real files. The output keeps empty, missing and extra lists separate so a reviewer can see multiple observations on the same record.
import csv
import io
def inspect_rows(text):
if not isinstance(text, str) or len(text) > 4096:
raise ValueError("expected a small decoded CSV string")
expected = ["code", "note", "status"]
reader = csv.DictReader(io.StringIO(text, newline=""),
restkey="__extra__", restval=None)
if reader.fieldnames != expected:
raise ValueError("header does not match this review profile")
result = []
for position, row in enumerate(reader, 1):
result.append({
"position": position,
"empty": [k for k in expected if row[k] == ""],
"missing": [k for k in expected if row[k] is None],
"extra": row.get("__extra__", []),
})
return result
example = "code,note,status\nA,,ready\nB,note\nC,note,ready,x\n"
for record in inspect_rows(example):
print(record)Interpret the three constructed records
Record A contains three fields, including an empty note between two delimiters. Its empty list contains note, while missing and extra are empty. Record B contains only code and note; its status appears in the missing list because no third field was supplied. Record C contains an additional x after its declared status, so its extra list contains that value. These are transparent observations about the constructed string. They do not assign a business meaning to an empty note or explain why the exporter emitted an extra value. Keep the observations distinct when asking for clarification.
Try a trailing delimiter next. A row ending with B,note, supplies an empty third field, whereas B,note supplies only two fields. That small difference is precisely what this exercise preserves. Also try a fourth empty field: C,note,ready, has an extra list containing an empty string. A report that merely says extra values are blank would lose the evidence that a fourth field existed. Record the count as well as a readable representation of the values when preparing a review message. The register owner can then distinguish layout changes from intentionally empty content.
Keep structural findings separate from repairs
Do not pad, trim or shift records during this first pass. Deleting an excess cell because it looks unimportant can move a real issue beyond the reviewer’s view. Filling an absent status with an empty string also erases the distinction established above. Instead, place the ordinal record reference, the three lists and the relevant original record in a private review note. Handle actual identifiers and sensitive field content according to the project’s established controls. The tutorial needs only invented values, and its output is not a public register or a substitute for an approved handoff record.
A completely blank physical row is another useful limit to document: DictReader does not turn it into an ordinary all-missing data record. If your agreement requires accounting for blank lines, retain the original file and add a separate physical-line review. Likewise, this function does not diagnose every malformed quoting pattern, guess delimiters, normalize Unicode or validate status vocabulary. Use a parser configuration matched to the supplied format, and document unsupported cases. A narrow check that states its limits gives a later reviewer a more reliable starting point than an import that silently cleans everything it cannot explain.
Carry a reproducible finding into the handoff
Before applying the technique to a copy of a real register, verify the example output and test the exact trailing-delimiter cases yourself. Then record the runtime version, header expectation and selected file revision. If the owner supplies a corrected export, rerun the same check on that separate revision and keep the first report available. Comparing the reports should answer whether the structural issue changed; it should not automatically pronounce the mission accepted. Connect a resolved layout finding to the separate content and project checks already required by the delivery agreement.
NiVO catalogue photography on this page provides aircraft context only. It does not depict the invented register or establish which software created a file. The practical result is a small vocabulary for a specific review: empty means a field was supplied without text, missing means the profile lacked a field, and extra means values exceeded its declared width. Keeping those labels visible helps the sender answer a precise question. Once the layout is agreed, the team can move on to identifier matching, coordinate interpretation and other substantive checks without having overwritten the evidence that prompted the discussion.



