Export column naming
How Fieldbase builds column names in the export. The convention is mechanical — same input, same output, every time — so you can predict the column from the YAML alone.
Core rules
Four rules produce every column name mechanically from the YAML alone. Once you know them, you can predict any column without running the survey — no execution needed.
1. qid is alphanumeric only — no underscores, no hyphens, no dots. Must match /^[A-Za-z][A-Za-z0-9]+$/. Valid: Q1, QBrand, QBrandUsage, Awareness. Invalid: Q_brand, Q-brand, Q.brand. The DSL parser rejects the invalid forms at compile time — hard constraint, not recommendation.
2. Underscore is reserved exclusively for the loop iteration suffix. An underscore appears in an export variable name only as the separator between the name body and the loop iteration code at the very end — Q1r1_3. Row codes, option codes, and column codes are separated from each other and from the qid by their structural prefix letter, not by underscores. See Loop suffixes for the full story.
3. Structural prefixes identify the axis inline. Three prefix letters, written directly adjacent (no separator before or after): r = row code, c = column code (gridNumber only), o = option code (multi, rank, gridMulti scale). A trailing code with no prefix is a loop iteration code.
4. Specify is a camelCase suffix on the variable name — Q1o99Specify for the specify text of option code 99, Q1r99Specify for row code 99. No underscore before it (that would look like a loop with iteration code specify).
str.split('_') always gives the body and the optional loop code — nothing else, no edge cases.Q1_r1_o2). Since v3.8.0 the entire header set is camelCase-with-prefixes (Q1r1o2) and the underscore is reserved for the loop suffix alone. Snake-case columns from a legacy fielding will not line up with the current export — regenerate them from the same source data if you need the new shape.Pattern by question type
| Question type | Pattern | Example |
|---|---|---|
single, open, number | qid | QBrand |
multi (one column per option) | qidoN | QFeatureso1, QFeatureso2 |
rank (one column per rank position) | qidoN = rank of code N | QTop3o1, QTop3o2 |
gridSingle, gridMulti | qidrN (one column per row) | QSatisfr1 |
gridNumber with direction: rows | qidrNcM | QBudgetr1c1 |
gridNumber with direction: cols | qidcNrM | QVolumec1r1 |
numberList, openList | qidrN | QSpendingr1 |
specify (attached text entry) | qidoNSpecify | QBrando99Specify, QSatisfr1Specify |
lookup (single-step) | qid, qidFieldName | QZip, QZipCity, QZipRegion |
lookup (cascading step) | qidStepId, qidStepIdField | QVehicleMake, QVehicleModelBodyType |
lookup (multi-select) | qidoN (chip N’s value) + qidFieldNameoN for fields | QSpecialtieso1, QSpecialtieso1Area |
cardSort (item → slot) | qidsN = slot N contents; qidoNSlot = which slot option N landed in | QSort_1s1, QSorto1Slot |
textAnnotation | qidwN (per-word mark) + qidTrace (JSON annotation blob) | QReactw1, QReactTrace |
imageAnnotation (pin / rect) | qidTrace (JSON) + qidCount + qidPosCount/qidNegCount | QPackTrace, QPackCount, QPackPosCount |
videoAnnotation (dial / reaction) | qidtN = trace value at second N | QAdt1, QAdt2, … QAdt30 |
| CBC / MaxDiff summary punch | qidVersion, qidNtasks | QCbcVersion, QCbcNtasks |
| CBC / MaxDiff per-task detail | Ships in the long companion, not the wide file | cbc_long, maxdiff_long |
| Loop iteration suffix (any of the above) | base_N | QBudgetr1c1_3 |
QPackAnnotations = a single unwieldy text column. Since v3.8.0 they materialize into typed columns following the rules above, so analysts can crosstab and pivot on them like any other punch. The JSON Trace columns are still present for tools that want the raw geometry.The gridNumber direction rule
gridNumber is the only question type whose column naming depends on a
property — direction.
direction: rows— totals shown per row → columns namedqidrNcMdirection: cols— totals shown per column → columns namedqidcNrM
Pick the direction that matches how the analyst wants to sum. Switching it later renames every column in the export.
Tri-state for coded options
When a question has coded options that fan out into one column per code
(multi, gridMulti), the column doesn’t store a simple 1/0. It stores
a tri-state:
| Value | Meaning |
|---|---|
1 | The option was shown to the respondent and selected. |
0 | The option was shown to the respondent and not selected. |
null | The option was not shown — masked by options.from, scale.from, or skipped via if. |
This distinction matters whenever you mask options at runtime. A null
means “they never saw this choice”, which is very different from “they
saw it and rejected it”. See Tri-state projection
for the full treatment.
Building a column name in Python
For analysis code or export-validation scripts, this is the exact rule expressed as a function:
import re
def format_col(qid, row=None, col=None, option=None,
field=None, loop=None, direction='rows'):
"""Build an export column name from its components."""
name = qid
if direction == 'rows':
if row is not None: name += f'r{row}'
if col is not None: name += f'c{col}'
else:
if col is not None: name += f'c{col}'
if row is not None: name += f'r{row}'
if option is not None: name += f'o{option}'
if field: name += field[0].upper() + field[1:]
if loop is not None: name += f'_{loop}'
return name
The leading record column
Every wide export starts with a record column — a persisted, monotonically-increasing case number assigned to each respondent at interview start. It’s stable across resubmits, deletes, and re-exports of the same fielding. Use it as the analyst-facing case identifier — the primary key for joins between the wide file, the long companions, and any custom overlays.
respondentId (a UUID) is also in the file, but record is the number analysts actually cite (“respondent 47 has a data-quality issue”). See Data Hub → Data View for the edit surface that operates on records.
What’s not a column
- Isolate opt-outs emit a single flag column — when an
isolate: Trueoption (e.g. “I don’t know” / “None of these”) is active, the question’s normal row / option / cell columns gonulland one flag column is added:<qid>r<code>for row-shaped types,<qid>o<code>forrank,<qid>c<code>for agridNumbercolumn axis, or<parent>r<code>formixGrid. The flag reads1when the opt-out is active. No per-row isolate columns are ever added — just the one flag per opt-out entry. infoquestions have no answer → no column.- Comments (
#,#[[ … #]], trailing#) are Python-inert everywhere and never touch the export. See Python essentials → Comments.
See also
- Tri-state projection — what
nullmeans in your data. - Loop suffixes — how loops compose with the naming rule.
- Long format — task-based export for CBC and MaxDiff, plus loop stacking.
- Formats — CSV / SPSS /
.sav/ XLSX / ASCII output engines. - Data Hub — the UI + endpoints that generate exports.
- Glossary: qid — what makes a
qidvalid.