Docs
Browse Docs
Field guide · Names and identity

Identifiers that lost their leading zeros

A code that starts with zero, such as a postal code or account number, was read as a number and the zeros were dropped.

What it looks like

Before
postal_codeemployee_id
2134417
0213400417
1000112045
After
postal_codeemployee_id
0213400417
0213400417
1000112045
Padding is safe here because both codes are known to be exactly five characters long.

How it happens

  • A spreadsheet guessed that a column of digits was numeric and stored it as a number.
  • A database column was defined as an integer when the code only looks like one.
  • A file was opened and saved again, and the conversion happened without anyone choosing it.

What it breaks

  • Joins to another table fail for exactly the rows whose codes begin with zero.
  • Postal codes from some regions become too short to be valid, so mail and tax lookups fail.
  • Very long numeric identifiers can also be rounded or shown in scientific notation, which destroys digits that padding cannot bring back.

How to spot it

  • Count values by length. A fixed-length code should have one length.
  • Check whether the short values are concentrated in one region or one range, which is what dropped zeros look like.
  • Look at alignment in a spreadsheet. Codes that sit to the right are being treated as numbers.

How to fix it

  • Treat identifiers as text from the moment the file is read, before any software guesses a type.
  • Pad back to the full width only when the code has one known, fixed length.
  • For codes of varying length, go back to the source. The number of zeros that were dropped is not recoverable from the value.

TermsLeading zeros, Identifier, Data type, Type coercion

Karg checks for many of these when it profiles a file, applies the fixes it is confident about, and sets the rest aside for your review. See how it works, or have our team clean your data for you.