Skip to Content

User_defined transform using Python script to keep only alpha numeric character

Input to the User_defined transform will be a Description field which will contain invalid character set as below.

Source

Name,Description

AAA,AAdesc@1

BBB,BBdesc$1

CCC,CCdesc*&1

DDD,DDKl@£$%[};’\D

Python script to remove the invalid character and keep only alphanumeric character

————————————————————————————————-

import re

var1 = locals()

var1[u’Description’] = record.GetField( u’Description’)

var1[u’Description’] = re.sub(“[^a-zA-Z0-9.]”,””,var1[u’Description’])

record.SetField(u’New_Description’,var1[u’Description’])

————————————————————————————————-

Target

DESCRIPTION,NEW_DESCRIPTION

AAdesc@1, AAdesc1

BBdesc$1, BBdesc1

CCdesc*&1, CCdesc1

DDKl@�$%[};’\D, DDKlD

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply