Export DSS input files (csv or txt) into XML
Hi dear,
I need to output a dataset into an XML format.
Here my input file : people.csv
Id; firstname ; lastname ; age ;date
PERSONID1 ; LUNA;HUANG ;10 ;31/01/2022
PERSONID2 ; PATRICK;FALL;90 ;11/01/2012
PERSONID3 ; KENDAL;CASANOVA;90 ;12/06/2009
I want my output file look like this:
<?xml version="1.0"?>
<document date="2021-12-31">
<people filename="peoples.csv" people_id="PERSONID1">
<FIELD fieldname="firstname" value="LUNA"/>
<FIELD fieldname="lastname" value="HUANG"/>
<FIELD fieldname="age" value="10"/>
<FIELD fieldname="date" value="31/01/2022"/>
</people>
<people filename="people.csv " people_id="PERSONID2">
<FIELD fieldname="firstname" value="PATRICK"/>
<FIELD fieldname="lastname" value="FALL"/>
<FIELD fieldname="age" value="90"/>
<FIELD fieldname="date" value="11/01/2012"/>
</people>
<people filename="people.csv " people_id="PERSONID3">
<FIELD fieldname="firstname" value="KENDAL"/>
<FIELD fieldname="lastname" value="CASANOVA"/>
<FIELD fieldname="age" value="90"/>
<FIELD fieldname="date" value="12/06/2009"/>
</people>
</document>
I have tried this script (input.png)
the output I get does not suit me. It looks like this (output.png)
Is there any way to do this in DataIku?
Best Answer
-
cbimou Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 12 Partner
Hi @CoreyS
Thanks for the suggestion. I finally found a solution by using folders as input for my flat file and as output for the xml. This way I get the Folder_IDs to easily use a python script to convert csv to xml.
Thanks