Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Parse a fixed-width mainframe extract

Python data engineering interview problem. Difficulty: intermediate. Pattern: Strings. About 15 minutes. Part of the Pro drill bank.

A nightly mainframe extract is fixed-width, not CSV. Each field lives in character positions defined by a spec. You must slice, not split on commas.

Parse fixed-width lines using the provided field spec.

Requirements

  • Slice each line by the spec widths in order.
  • Strip padding as the tests require.

Constraints

  • lines: raw extract rows.
  • spec: field name to width (or start/end) mapping.
  • Short lines should follow the spec (pad vs skip).
  • Keep one output record per input line.

Examples

Input: parse_fixed_width(['SKU1widget'], [('sku', 0, 4), ('name', 4, 6)]) Output: [{'sku': 'SKU1', 'name': 'widget'}] This input follows the stated rules and produces this output.

Topics: lakebench, python, file/data-processing.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Parse a fixed-width mainframe extract

Interview-style drill: Parse a list of fixed-width text lines into structured records using column offsets.

Parse fixed-width lines using the provided field spec.