I want to delete . , # in attribute table using field calculator (VB Script or Python).

How can I remove these using this example address: N. First St., Unit #1 (I don't need city or state name)

I checked several websites, but I couldn't find the clear answer.

How to remove comma from combined fields which should be null?


  • 2
    Which field calculator are you using? ArcGIS for Desktop, QGIS and probably other GIS software have this tool. – PolyGeo Apr 1 '15 at 20:39
  • It's ArcGIS for Desktop 10.2.1 version – Ginny Apr 6 '15 at 14:36

Use the built-in str.translate(table[, deletechars]), but with None for the table argument (requires at least Python 2.6). E.g.:

'N. First St., Unit #1'.translate(None, '.,#')


'N First St Unit 1'

Or for ArcGIS' calculator, this can be a one-liner:

!yourField!.translate(None, '.,#')
| improve this answer | |
  • Simple, I like this one. – ianbroad Apr 1 '15 at 21:47

Use python to calculate values in new field:

filter(lambda x: x not in ".,#", !yourField!)
| improve this answer | |

in the python code block:

import re

def strip(value):
    return re.sub('[.,#]','',value)

and then in the field calculator:

| improve this answer | |

And another way.

Python Pre-Logic Script Code:

def remove(text):
    for char in [".", ",", "#"]:
        if char in text:
            text = text.replace(char, "")
    return str(text)

Bottom part:

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.