Python code to keep only alphanumeric character
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
Thanks for this code. This was a requirement in one of our previous work. Will try this out.
Useful tip... . Thanks
Thanks Nishil...Was in search of this.. 🙂 really helped..
Very useful one
Good one..
Very Useful Nishil