Topic
3 replies Latest Post - ‏2012-12-10T13:41:17Z by Muk1234
Muk1234
Muk1234
22 Posts
ACCEPTED ANSWER

Pinned topic csv to xml

‏2012-12-07T07:16:18Z |
hello, I have a csv file muk.csv. I want to convert the input values in the csv file to an xml file. I don't know how to interpret the headesr s in the csv file, I mean i just want the values to be mapped and not the headers. The header names come as an output in the generated xml file. So if I have the following input: Name,Id,TotalRec
Muks,mp1,2
TransID,Amt,Desc
trans1,$100,asd
trans2,$200,dld
Expected output: <Id>Muks</Id>
<transId>trans1</transId>
<AmtProcessed>100</AmtProcessed>
<Details>asd</Details>
<Id>Muks</Id>
<transId>trans2</transId>
<AmtProcessed>200</AmtProcessed>
<Details>dld</Details>
what i am getting is something like this: <Id>Name</Id>
<transId>Id</transId>
<AmtProcessed>TotalRec</AmtProcessed>
<Details>Muks</Details>
<Id>mp1</Id>
<transID>2</transId>.......ans so on
So basically it is treating header names as input. I just want the values. Can anyone help me on this please?
Updated on 2012-12-10T13:41:17Z at 2012-12-10T13:41:17Z by Muk1234
  • SystemAdmin
    SystemAdmin
    6184 Posts
    ACCEPTED ANSWER

    Re: csv to xml

    ‏2012-12-07T11:27:03Z  in response to Muk1234
    If you can't get rid of the headers, the solution would be to ignore them either via the type tree (which means creating a specific group for the headers) or only process from the second one (using EXTRACT to select what you pass to the fmap)
    • Muk1234
      Muk1234
      22 Posts
      ACCEPTED ANSWER

      Re: csv to xml

      ‏2012-12-10T13:41:17Z  in response to SystemAdmin
      Thankyou Laurent and Paul. I made an extra group of headers in the type tree. It worked.

      Regards
      Muk1234
  • paul.brett
    paul.brett
    443 Posts
    ACCEPTED ANSWER

    Re: csv to xml

    ‏2012-12-07T12:02:24Z  in response to Muk1234
    As a follow-up to Laurent's suggestion, as you don't need to map the header row, just define it as a text blob with a terminator of whatever is currently your row delimiter (I assume a <NL> character).

    You're not mapping this data, so you can chuck it all into a very simple Typetree object for greater mapping speed.