on 07-13-2011 11:45 PM
Hi Experts
I have a type file CSV which has the following structure:
-
Date,Outlet,Car,Code,InOut,Time,N
20110515,9,E26,14,E,083150,1
20110515,9,E26,,S,083324,1
20110515,11,E26,15,E,103200,1
20110515,11,E26,,S,103420,1
20110515,15,E26,15,E,125247,1
20110515,15,E26,,S,130042,1
-
Can anyone tell me how to assign the value of the Code column of the previous line to the next line that has the "Code" empty (,,)?
Required to create a function? Or with a standard function and which is?
thanks
Hello,
Can anyone tell me how to assign the value of the Code column of the previous line to the next line that has the "Code" empty (,,)?
Required to create a function? Or with a standard function and which is?
Yes, this needs to be a user-defined function in message mapping.
In your message mapping, the logic is similar to this
Code -> mapWithDefault -> removeContext -> UDF -> splitByValue:eachValue -> Target
UDF is context type
argument is input
for(int a =0;a<input.length;a++){
if(a==0){
result.addValue(input[a]);
}
else{
if(input[a].trim().equals("")){
result.addValue(input[a-1]);
}
else{
result.addValue(input[a]);
}
}
}
There is an added logic, what if your first code is blank?
Hope this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I mean the following clarification
the input file has the following structure:
Date,Outlet,Car,Code,InOut,Time,N
whose values are as follows:
20110515,9,E26,14,E,083150,1
20110515,9,E26,,S,083324,1
20110515,11,E26,15,E,103200,1
20110515,11,E26,,S,103420,1
20110515,15,E26,15,E,125247,1
20110515,15,E26,,S,130042,1
I want the target structure of the output file will is as follows:
20110515,9,E26,14,E,083150,1
20110515,9,E26,14,S,083324,1
20110515,11,E26,15,E,103200,1
20110515,11,E26,15,S,103420,1
20110515,15,E26,15,E,125247,1
20110515,15,E26,15,S,130042,1
i.e. IF there is an record with the empty "Code" THEN put the "Code" of the previous record.
Thanks, I hope this clarification is sufficient to help me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.