Use Case: Here, we will Merge the content of two files into one csv file where there is no common field.
Consideration: we will map the two files sequencially. That means, for 1st row of file1 to 1st row of file2, 2nd row of file1 to 2nd row of file2......nth row of file1 to nth row of file2.
For example,
File1.csv:
FirstName,LastName
sid,das
dip,chak
File2.csv
sid@gmail.com
dip@gmail.com
Merged file:
FirstName,LastName
sid,das,sid@gmail.com
dip,chak,dip@gmail.com
Highlevel steps:
- Create a scheduled orchestration with a name.
- Drag and drop the FTP adapter and read both the source files one by one.
- Drag and drop the FTP adapter to write the final merge file. Here, in the map, for each file1 record, we will create a variable named "i" with value "position()" and that postion we will use to fetch the value from file 2 hsing $i.
<xsl:template match="/" xml:id="id_11">
<nstrgmpr:WriteFile xml:id="id_12">
<ns28:FileMergedRecSet>
<ns28:FileMergedRec>
<ns28:C1>
<xsl:value-of select="'Fname'"/>
</ns28:C1>
<ns28:C2>
<xsl:value-of select="'Lname'"/>
</ns28:C2>
<ns28:C3>
<xsl:value-of select="'Email'"/>
</ns28:C3>
</ns28:FileMergedRec>
<xsl:for-each select="$readFile1/nsmpr1:SyncReadFileResponse/ns21:FileReadResponse/ns22:File1RecSet/ns22:File1Rec">
<xsl:variable name="i" select="position()"/>
<ns28:FileMergedRec>
<ns28:C1>
<xsl:value-of select="ns22:FirstName"/>
</ns28:C1>
<ns28:C2>
<xsl:value-of select="ns22:LastName"/>
</ns28:C2>
<ns28:C3>
<xsl:value-of select="$readFile2/nsmpr2:SyncReadFileResponse/ns25:FileReadResponse/ns24:File2RecSet/ns24:File2Rec[$i]/ns24:EMail"/>
</ns28:C3>
</ns28:FileMergedRec>
</xsl:for-each>
</ns28:FileMergedRecSet>
</nstrgmpr:WriteFile>
</xsl:template>
No comments:
Post a Comment