Skip to main content

fixlengths

Ensures all rows have the same number of fields by padding shorter rows or truncating longer rows. Useful for data cleaning workflows.

Write with --output. A trailing path is not a positional argument.

# Pad rows with empty string (default)
undatum fixlengths data.csv --strategy pad --output output.csv

# Pad with custom value
undatum fixlengths data.jsonl --strategy pad --value "N/A" --output output.jsonl

# Truncate longer rows
undatum fixlengths data.csv --strategy truncate --output output.csv

Reference​

Reads: any readable format · Writes: any writable format; CSV/TSV/JSON/JSON Lines on stdout · Memory: streaming, two passes over the input · Engines: python

undatum fixlengths [OPTIONS] INPUT_FILE
ArgumentDescription
INPUT_FILEPath to input file. (required)
OptionDescriptionDefault
-o, --output TEXTOptional output file path. If not specified, prints to stdout.
--strategy TEXTStrategy: 'pad' (default) or 'truncate'.pad
--value TEXTValue to use for padding (default: empty string).
-d, --delimiter TEXTCSV delimiter character (auto-detected when omitted).
--quotechar TEXTCSV quote character (iterabledata default '"' when omitted).
--encoding TEXTFile encoding (e.g., 'utf8', 'latin1').
--verbose / --no-verboseEnable verbose logging output.--no-verbose
-F, --format-in TEXTOverride input file format detection (e.g., 'csv', 'jsonl').
--table, --sheet TEXTTable or sheet name for multi-table sources (Excel, SQLite, lakehouse).
--start-page INTEGERSheet index (0-based) for Excel files.0
--trustAcknowledge pickle deserialization risk when reading pickle sources.
--on-error TEXTParse-error policy: raise (default), skip, or warn.
--error-log TEXTAppend parse errors as JSONL (use with --on-error skip or warn).
--flatten-nestedUnfold nested dict / array-of-dict fields into dotted paths (e.g. city.lat).
--max-nested-depth INTEGERWith --flatten-nested, maximum nest depth to unfold (engine default 5).
--keep-nested-parents / --no-keep-nested-parentsWith --flatten-nested, keep parent dict/array fields alongside dotted children.--keep-nested-parents
-O, --format-out TEXTOutput format (e.g. csv, jsonl, parquet). Defaults to the --output extension, or to the input's text format on stdout.

See also shared options.