Skip to content

Instantly share code, notes, and snippets.

@maptastik
Last active Nov 7, 2015
Embed
What would you like to do?

In the Field Calculator:

  1. Select "Python" as your parser

  2. Check "Show code block".

  3. Paste the following into the code block

def leadZero(val):
 if len(str(val)) == 7:
  return str(0) + str(val)
 else:
  return str(val)
  1. In the bottom text block:
leadZero(!whatever_the_name_of_the_numeric_field_is!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment