on 08-31-2011 6:56 PM
Hi experts
Can anyone help me to tell me:
How to make IP can take a value of the first record/occurrence and the last record in CSV file?
I need to take the first and last to put StarTime of first record y StopTime of last record in the target file
This is my Original CSV File
20110820,220DNE0220,140.13 ,0.000 ,E01,0
20110820,240FGC4280,103.80 ,0.000 ,E01,0
20110821,220DNE0220,142.58 ,0.000 ,E01,0
20110821,240FGC4280,88.70 ,0.000 ,E01,0
20110822,220DNE0220,151.92 ,0.000 ,E01,0
20110822,240FGC4280,91.47 ,0.000 ,E01,0
Where:
The firts field is date.
I require it so my Target File
20110820,20110822,140.13 ,0.000 ,E01,0
20110820,20110822,103.80 ,0.000 ,E01,0
20110820,20110822,142.58 ,0.000 ,E01,0
20110820,20110822,88.70 ,0.000 ,E01,0
20110820,20110822,151.92 ,0.000 ,E01,0
20110820,20110822,91.47 ,0.000 ,E01,0
Thaks..
Hi lizcam,
A. Use FCC at sender side, it will convert CSV to XML like this
Input XML
<documentName>
<recordset>
<record>
<Time>20110820</Time>
<ID>220DNE0220</ID>
<Quan>140.13</Quan>
<Volume>0.000</Volume>
<Auc>E01</Auc>
<No>0</No>
</record>
</recordset>
</documentName>
Create a target DT like this
Output XML
<recordset>
<record>
<StartTime>20110820</StartTime>
<EndTime>20110822</EndTime>
<Quan>140.13</Quan>
<Volume>0.000</Volume>
<Auc>E01</Auc>
<No>0</No>
</record>
</recordset>
In MM,
1.Time -> CopyValue[0] -> StartTime
2.Time -> below UDF -> EndTime
3.Quan -> Quan
4.Volume -> Volume
5.Auc -> Auc
6.No -> No
UDF u2013 Execution type u2013 All values of Queue
public void getLastTimeValue(String[] inputEndTime, ResultList result, Container container) throws StreamTransformationException{
result.addValue(inputEndTime[inputEndTime.length-1]);
}
B. At receiver use again FCC to convert XML to CSV.
FYI. If you want to optimize more, you can use
1.globalContainer concept OR
2.u201CAttributes and Methodsu201D, declare are String. Store the EndTime using one UDF and write another UDF to retrieve it.
Regards,
Raghu_Vamsee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raghu Vamsee
I have two questions:
1. How to put throws StreamTransformationException in the name of the UDF?
in my UDF is as follows:
public void getLastTimeValue(String[] inputEndTime, ResultList result, Container container){
result.addValue(inputEndTime[inputEndTime.length-1]);
}
2. when I do a test, does the following: in the first record is displayed the StartTime and EndTime but in the second record is not displayed the EndTime
I can comment because it failed?
Thanks
1,000 Thanks Raghu
You helped me, but in my case I just had to make a small change to the field EndTime:
2. Time -> below UDF -> CopyValue[0] -> EndTime
thus worked in the next records.
Thanks¡¡¡¡¡
Hi Satyanarayana:
your suggestion throws some errors I can not correct, but thank you very much.
Now I need to add another field to get yesterday in the target field
I tested with CurrentDate Function - 1 but i can not get yesterday automatically.
can someone help me? please
Hi,
You can do this using UDFs,
Define 2 variable in JAVA section as below:
String n1, n2;
and
write a UDF like:
n1 = a[0];
int i = a.length;
n2 = a[i-1];
-
In another UDF you can write these values like
return n1+"";
I hope it helps.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
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.