Skip to main content

Friendly Clean (fc) — Proposal

Name collision

fc is now a live command: filter-friendly-current (keyboard shortcut z Shift+C) filters the column under the cursor. See Filtering. Pick a different longname for Friendly Clean when implementing this proposal, for example fcl, or move it behind the Space palette with an unambiguous name.

A proposed batch data-cleaning command that chains multiple cleaning operations in one pass. Inspired by real data quality issues found in the practice files under 04-cleaning/.

The Problem​

Real-world CSV data has recurring issues that require multiple manual steps:

ProblemExampleSource
Inconsistent casingcompleted, COMPLETED, Completed01-dirty_orders.csv
Negative values-50.00 amount01-dirty_orders.csv
Non-numeric in numeric columnabc in amount01-dirty_orders.csv
Leading/trailing whitespacecommon in CSVsVarious
Null/empty cellsblank region01-dirty_orders.csv
Duplicate rowsAlice row repeated 3x01-dirty_orders.csv
Zero values that should be null0.00 amount01-dirty_orders.csv
Missing emailsCarol, Grace, Kateusers.csv
Missing datesblank last_loginusers.csv

Proposed Syntax​

Space fc Enter # prompt: fc: <col>|* <op>[, <op> ...] [, <col> <op>...]

Operations​

OperationWhat it doesApplies to
lowercase.lower() on texttext columns
uppercase.upper() on texttext columns
trim.strip() whitespaceall columns
absabs() on numericnumeric columns
to-numericCast to float, flag errorsnumeric columns
fill-downCopy non-null from previous rowany column
fill-missingReplace empty cells with placeholder textany column
dedupeRemove duplicate rows (keeps first)all *
zero-to-nullReplace 0 with emptynumeric columns
strip-punctuationRemove ,.-_/ from texttext columns

Column targeting​

Follows the same convention as fr:

InputTarget
status lowercaseSingle column
* trimAll visible columns
amount abs to-numericChained ops on same column
status lowercase, * trimComma separates clauses
status lowercase and amount absCross-column via and

Real Examples​

Example 1: Clean 01-dirty_orders.csv​

Raw data:

amount status region
150.00 completed sg
-50.00 completed
200.00 COMPLETED sg
abc pending jk
150.00 completed sg
shipped my
Space fc → * trim, amount abs to-numeric, status lowercase, region fill-down, * dedupe

Result:

amount status region
150.00 completed sg
50.00 completed sg
200.00 completed sg
#ERROR pending jk
150.00 completed sg
0.00 shipped my

Each step:

StepBefore → After
* trimNo visible change (whitespace stripped)
amount abs-50.00 → 50.00
amount to-numericabc → #ERROR (flagged)
status lowercaseCOMPLETED → completed
region fill-downblanks filled from previous row
* dedupeAlice duplicate removed

Example 2: Clean users.csv​

Space fc → email fill-missing, last_login fill-missing, * trim
  • Missing emails → placeholder no-email@unknown
  • Missing last_login → placeholder never
  • All fields trimmed

Why It Matters​

Without fc:

  • g* one pair at a time for text normalization
  • g= with Python expressions for numeric transforms
  • Manual navigation to each column
  • No built-in abs, fill-down, or dedupe as one-step operations

With fc:

  • Chain multiple cleaning operations in one command
  • Same column-targeting convention as ff and fr
  • Batch undo with U (same mechanism as fr)
  • No Python syntax needed

Implementation Notes​

  • Build as keybind-source/38-friendly-clean.py
  • Each operation is a simple Python function on the cell value
  • Chained operations on same column apply in order (left to right)
  • Uses the same vd.addUndo() batch-undo pattern as fr
  • Follows same and/or / comma parsing as ff and fr

This is a proposal — not yet implemented. See the built commands ff (Filtering) and fr (Incremental & Replace) for the working pattern.