Parse a variable and map data to target element
AnsweredI have a global variable that has file name in it. I am trying to parse the variable and extract parts of it and map to elements in my target schema.
Example:
The file name will be in the format a_b_c.csv. I would like to extract a, b, c and map them to 3 different elements in output. a/b/c can contain '_' in them as well. The length of a/b/c are variable.
My example file name would be 36172_Company_Name_2016-05-26.
Here, a = 36172, b=Company_Name, c=2016-05-26
There will be underscores only in b(CompanyName).
-
Official comment
Here's a high level approach
1) Create a local variable varID = substring before _ InputField
This will capture the first segment a
2) Create a local variable varNameDate = substring after _ InputField
This will capture segments b and c
3) Create a local variable varFirstName = substring before _ varNameDate
This will capture the full company name or the first part of the company name
4) Create a local variable varSecondNameDate = substring after _ varFirstName
This will capture the second company name or the secondcompanyname_date5) 5) Create a local variable varDate
WHEN CONDITION{ contains($varSecondNameDate,'' ) } VALUE=[ substring-after( $varSecondNameDate,'' ) ] OTHERWISE VALUE=[$varSecondNameDate]
6) Create a local variable varSecondName
WHEN CONDITION{ contains($varSecondNameDate,'' ) } VALUE=[ substring-before( $varSecondNameDate,'' ) ] OTHERWISE VALUE=['']
7) Create a local variable varName
WHEN CONDITION{$varSecondName=''} VALUE=[ $varFirstName] OTHERWISE VALUE=[ concat( $varFirstName, '_' ,$varSecondName ) ]
Please sign in to leave a comment.
Comments
1 comment