Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

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

6 Comments
Labels in this area