Skip to content

RegTab

Turn tables made for people into machine-readable records.

RegTab is a data-wrangling toolkit for tables designed for reading rather than querying — spreadsheets, cross-tabs and reports with hierarchical headers and compound cells. At its core is RTL (Regular Table Language), a pattern DSL that does for tables what regular expressions do for strings: a pattern describes the table's repeating layout and how the matched cells map to attributes, values and records.

How it works

An RTL pattern mirrors the layout of the table it matches — here, a cross-tab of airline on-time data: a header row of airlines, then repeated airport rows. Cell values map to attributes (->AVP) and records (->REC):

[ [] [VAL : 'AIRLINE'->AVP]+ ]
[ [VAL : 'AIRPORT'->AVP]
  [VAL : (COL, ROW, CL)->REC, 'ND'->AVP " " VAL : 'MON'->AVP]+ ]+
See it applied to a table

The source cross-tab, with compound cells like 31 Jan holding two values — a number and a month:

CA HU
IKT 0 Jan 8 Feb
SVO 31 Jan 40 Feb

Matching the pattern unpivots it into a flat record set — one record per data cell, ready for a DataFrame or CSV:

ND AIRLINE AIRPORT MON
0 CA IKT Jan
8 HU IKT Feb
31 CA SVO Jan
40 HU SVO Feb

Tools

jRegTab

The reference implementation of RegTab in Java. Use RTL as a standalone or embedded DSL.

pyRegTab

A Python port of jRegTab; extracted record sets convert straight to pandas DataFrames.

vscode-rtl

Full RTL support in VS Code: highlighting, as-you-type diagnostics and completion, and live match preview against sample tables.