Pentaho Tools :

Pentaho C-Tools(CDE,CDF,CDA),Pentaho CE & EE Server,OLAP-Cubes,Analysis using Pivot4J, Saiku Analytics, Saiku Reporting, Ad-hoc Reporting using Interactive Reporting Tool,Dashboards,Reports using PRD, PDD,Data Integration using Kettle ETL,Data Mining usign WEKA,Integration of Servers with Databases,Mobile/iPad compatible Dashboards using Bootstrap Css,Drilldown dashboards,Interactive Dashboards

Tuesday, 5 May 2015

Tip : Kettle ETL : Get only first string in a comma separted text - Modified Java Script Step Example

Problem Statement : 
Get first sting in below text value in a field
"Children out of school, primary, female"
Solution : 
Children out of school

Tool set : PDI 5.3 CE, Excel Data File(or Table input)

1) Get data from input file or input table ( Input-> Table input step).
   Note that the filed name is : indicator_name from which we want to get first string from a comma separated text.   

2) Take Modified Java Script Value step (Scripting -> MJSV) and write below expression
var indicator_sub_name = indicator_name.split(",")[0]

* Hop Table input to MJSV
* After writing expression click on "Get fields" button in MJSV
* The variable will be a new stream filed to the next step

3) Add select values step and preview the transformation.( ignore the unwanted fields in ignore tab).

Quick Image:

Hope this tip helps some one ...!!!