Pentaho

 View Only

 Pentaho Java script - Multi line field parsing

  • Pentaho
  • Kettle
  • Pentaho
  • Pentaho Data Integration PDI
vikas reddy's profile image
vikas reddy posted 10-01-2018 04:52

I have a multi line field populated with some specific values I need to parse and write to new fields.

Field:

 

001

AIR CONDITIONING

UNK

TYPE UNKNOWN

30.0

 

 

005

EXTERIOR WALL

FRB

FRAME BRICK

20.0

 

 

006

ROOFING

COS

COMPOSITION SHINGLE

50.0

 

Here for an example, I want to check if the field has a string 'EXTERIOR WALL', and if it does I want to parse the next three lines 'FRB' , 'FRAME BRICK' and 20.0 to new fields:

 

Category          Type     Desc                    Amount

Exterior Wall     FRB     FRAME BRICK     20.0

Roofing               COS     COMPOSITION     50.0

 

The field will always be in the above format with multiple segments of data separated by spaces.

I have checked and didn't find any useful resources for this problem. Any suggestions please?


#Pentaho
#Kettle
#PentahoDataIntegrationPDI
David Marlow's profile image
David Marlow

Looks to me like you just need to put your records together. Attached is a small transformation and data file  that will do that. I'm sure there are other ways. After the rows are together you can do whatever you want with them. You will have to change the input step to reflect however you are getting your data ..Data Base...File....etc.

PS: sorry for the names,reminders I don't need them

Data Conversion's profile image
Data Conversion
Data Conversion's profile image
Data Conversion
Attachment  View in library