cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BTP CPI - CSV to XML Converter escaping special characters.

Nijith
Explorer
0 Kudos
3,849

How can I ignore special character in a csv file when using CSV to XML converter component in CPI

E.g. I have a csv file as follows:

EmpId,Name,Address

1,Noel,"Main Street 1,Country Road "

2,Joel,"Main Street 2,Country Road " And when I process the data using the CPI converter it splitting the address into 2 .So is there a way I can escape the , inside the address and get the address as 1 after converting to XML

View Entire Topic
Nijith
Explorer
0 Kudos

Hi bellizia_capgemini ,

Thank you so much for your prompt reply.I was able to figure out what the issue was ,it was because of the white space that I had in my data because of which it was not working as expected ,once I removed them it worked .

Sample data with spaces :

EmpId|Name| Address|Age

1|Noel| "Main Street 1|Country Road "|24

2|Joel| "Main Street 2|Country Road "|25

Corresponding XSD:

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="Employees">

<xs:complexType>

<xs:sequence>

<xs:element name="Employee" maxOccurs="unbounded" minOccurs="0">

<xs:complexType>

<xs:sequence>

<xs:element type="xs:byte" name="EmpId"/>

<xs:element type="xs:string" name="Name"/>

<xs:element type="xs:string" name="Address"/>

<xs:element type="xs:string" name="Age"/>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:schema>


And the output generated with it is as follows :

<?xml version="1.0" encoding="UTF-8"?> <Employees> <Employee> <EmpId>EmpId</EmpId> <Name>Name</Name> <Address>Address</Address> <Age>Age</Age> </Employee> <Employee> <EmpId>1</EmpId> <Name>Noel</Name> <Address>"Main Street 1</Address> <Age>Country Road "</Age> </Employee> <Employee> <EmpId>2</EmpId> <Name>Joel</Name> <Address>"Main Street 2</Address> <Age>Country Road "</Age> </Employee> </Employees>

But if I remove the white space ie. old sample data.

1|Noel| "Main Street 1|Country Road "|24

2|Joel| "Main Street 2|Country Road "|25

to new sample data

1|Noel|"Main Street 1|Country Road "|24

2|Joel|"Main Street 2|Country Road "|25

it works without a problem .Thank you once again for helping me out.

<?xml version="1.0" encoding="UTF-8"?> <Employees> <Employee> <EmpId>EmpId</EmpId> <Name>Name</Name> <Address>Address</Address> <Age>Age</Age> </Employee> <Employee> <EmpId>1</EmpId> <Name>Noel</Name> <Address>Main Street 1|Country Road</Address> <Age>24</Age> </Employee> <Employee> <EmpId>2</EmpId> <Name>Joel</Name> <Address>Main Street 2|Country Road</Address> <Age>25</Age> </Employee> </Employees>