on 09-20-2016 2:56 AM
Hi folks,
I have an incoming CSV file with header line.
I want to use the "CSV to XML Converter" to convert the CSV file to XML file start from line 2.
Can the "Record Marker in CSV" achieve that?
Test Data :
employeeid, first_name, last_name
1, Bean, Jelly
2, Butter, Peanut
Expected Result:
<?xml version="1.0" encoding="UTF-8"?>
<DT_HCI_Conversion>
<Line>
<employeeid>1</employeeid>
<first_name>Bean</first_name>
<last_name>Jelly<last_name>
</Line>
<Line>
<employeeid>2</employeeid>
<first_name>Butter</first_name>
<last_name>Peanut<last_name>
</Line>
</DT_HCI_Conversion>
Thank you.
Regards,
YingHeng
Helo YingHeng,
You need to add script step before convertor step and use the below script.
Script:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message)
{
def body = message.getBody(String.class);
body = body.substring(body.indexOf('\n')+1);
message.setBody(body);
return message;
}
Please note a we don't have option in CSV to XML convertor.
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Helo Sriprasad,
Thank you for your quick respond.
Ya, we're aware of adding a script step before converter can achieve the same result.
But we want to check is there any alternative way can achieve the same result by using the CSV to XML Converter itself.
By referring to the documentation, it stated the field of "Record Marker in CSV" can control starting point of the content.
Do you have any idea to how utilize "Record Marker in CSV" field?
Thank you.
Regards,
Ying Heng
Hello YingHeng,
Yes you can utilize the above option.
For Example if you add record marker as 'RECSTART'.
1) All the rows in your CSV having first column RECSTART will be considered for conversion.
2) Records without having first column value RESSTART will be ignored for conversion.
Convertor Configuration:
Input:
Output:
I guess in your case leave the record marker blank in first row and have the record marker for rest of the rows in your csv.
Regards,
Sriprasad Shivaram Bhat
Hi Ying,
In sender file channel with message protocol as FCC, where you can see a parameter Document Offset on the control conversion tab. The Document Offset is use to ignore the number of lines.
example: If you provide the value as "1" for document offset it will ignore the first line from the file and which is your requirement here.
Thanks
Sagarika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ying,
A suggestion from my side.
We have an option of Document Offset in File Adapter (FCC is enabled under Message protocol). This parameter asks for the number of lines to be skipped(starting from the first line) while processing a CSV file. For your requirement, you need to set this value as 1.
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.