Skip to content

Instantly share code, notes, and snippets.

@maptastik
Last active November 7, 2015 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maptastik/479efea138919d23b0d2 to your computer and use it in GitHub Desktop.
Save maptastik/479efea138919d23b0d2 to your computer and use it in GitHub Desktop.

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