How to use User_Defined Transform in Data Services 4.x using Python Part-1
In this article we are explaining How to use Base_UserDefined transform step by step with an example of Replacing Special characters from the
This transform provides an interface to do anything that you can write Python code to do. You can use the User-Defined transform to create new records and data sets, or populate a field with a specific value, just to name a few possibilities.
- Create Input File and place a Base_UserDefined transform of Data Services and link the transform with the file .
- Open Base_UserDefined in the Input tab of the transform, drag and drop Input column of the input schema to the Input Schema Column Name so as to map with the Transform Input Field Name .
3. Check the Options tab and Click on Edit Options Button to customize the transform.
- Check Per record , then select Python Expression Editor and Click on Launch Python Editor Button to open the Python Editor .
(Option :- Per Record:- To deal all record independently ,Per collection:- Build a group of records on basis of Break group conditions like Base_match transform in this example we will go with Per record option and in next Topic we will proceed with Per collection option )
- Python Editor:- a.) I/O Field :- Insert the Input/Output fields according to requirement by Right clicking on particular option Input Fields / Output Fields then click on Insert give the field name and length of field . b.) Python API :- Python functions GetField to get the input field value and SetField to set output field value. c.) Editor :- Write your Python code here .
(For more details about code refer any Python Book)
- On the Output tab select the fields of interest.
7. Result :-
Please find the input and the output dataset generated as screenshots below:
In Part-2 I will explain used Python code in detail