Skip to Content
avatar image
Former Member

CSV to XML converter issue

I have a csv file that goes like

abc,1,2,

x,1,2,3,4,5,

x,q,w,e,r,t,

x,a,s,d,f,g,

123,1,

321,1,2,

So I have a header row and 2 rows at the end that do not follow the pattern as the rest of the rows. But all the other rows start with the same value.

So i used

Record Marker in CSV: x

But i got an exception:

CsvToXmlConversionException: XSD schema is incompatible with CSV payload. The XSD schema provided contains 6 records; CSV payload contains 6 records.

Is there something i missed to get it working.

(It does work if i remove the header and 2 footer fields and not specify "Record Marker in CSV").

Or Is there a better way to handle such a csv?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jul 12, 2017 at 06:16 AM

    Hello Shubham,

    In your XSD you must not consider Record Marker then it works perfectly [ basically it removes first column if you mentioned record marker ].

    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    	<xs:element name="Personal_MT">
    		<xs:complexType>
    			<xs:sequence>
    				<xs:element name="Personal" maxOccurs="unbounded" minOccurs="0">
    					<xs:complexType>
    						<xs:sequence>
    							<xs:element type="xs:string" name="F1"/>
    							<xs:element type="xs:string" name="F2"/>
    							<xs:element type="xs:string" name="F3"/>
    							<xs:element type="xs:string" name="F4"/>
    							<xs:element type="xs:string" name="F5"/>							
    						</xs:sequence>
    					</xs:complexType>
    				</xs:element>
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>
    </xs:schema>
    
    
    

    It works perfectly fine for above XSD resulting below output.

    <?xml version="1.0" encoding="UTF-8"?>
    <Personal_MT>
    	<Personal>
    		<F1>1</F1>
    		<F2>2</F2>
    		<F3>3</F3>
    		<F4>4</F4>
    		<F5>5</F5>
    	</Personal>
    	<Personal>
    		<F1>q</F1>
    		<F2>w</F2>
    		<F3>e</F3>
    		<F4>r</F4>
    		<F5>t</F5>
    	</Personal>
    	<Personal>
    		<F1>a</F1>
    		<F2>s</F2>
    		<F3>d</F3>
    		<F4>f</F4>
    		<F5>g</F5>
    	</Personal>
    </Personal_MT>
    

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 12, 2017 at 06:40 AM

    Hello Sriprasad,

    Thanks for the Reply. It Works Perfectly.

    Regards,

    Shubham

    Add comment
    10|10000 characters needed characters exceeded