<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add row ID for Header and Line in a CSV File in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290078#M63398</link>
    <description>&lt;P&gt;1rst, use a tFileInputDelimited instead of a tFileInputFullRow and untick the option&amp;nbsp;&lt;SPAN&gt;"&lt;EM&gt;check each row structure against schema&lt;/EM&gt;".&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;Then you need to memorize the "id" each time a new "header" line is coming from the input flow.&lt;/P&gt; 
&lt;P&gt;You can achieve this&amp;nbsp;using a pair of tMap variables:&lt;/P&gt; 
&lt;UL&gt; 
 &lt;LI&gt;the 1rst one (called "id" in my example) get the value from the input row when the "header" field contains the keyword "header", else its value is got from the 2nd var called "lastId"&lt;/LI&gt; 
 &lt;LI&gt;after that, the value of the variable "lastId" is overwritten by the value of the variable "id"&lt;/LI&gt; 
&lt;/UL&gt; 
&lt;P&gt;Got it?&lt;/P&gt; 
&lt;P&gt;Here is how it looks like in the tMap:&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lwuv.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/140355i22AC1E871D3B05C0/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lwuv.png" alt="0683p000009Lwuv.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;And the result as expected:&lt;/P&gt; 
&lt;PRE&gt;[statistics] connecting to socket on port 3565
[statistics] connected
.----+------+----+---.
|     tLogRow_42     |
|=---+------+----+--=|
|id1 |header|id2 |neg|
|=---+------+----+--=|
|id_1|Header|id_1|neg|
|id_1|Detail|25  |   |
|id_1|Detail|20  |   |
|id_2|Header|id_2|neg|
|id_2|Detail|10  |   |
|id_2|Detail|7   |   |
'----+------+----+---'

[statistics] disconnected&lt;/PRE&gt; 
&lt;P&gt;Fianlly you just have to put the result into a tFileOutputDelimited without the header line and that's all.&lt;/P&gt;</description>
    <pubDate>Sat, 21 Apr 2018 18:45:51 GMT</pubDate>
    <dc:creator>TRF</dc:creator>
    <dc:date>2018-04-21T18:45:51Z</dc:date>
    <item>
      <title>Add row ID for Header and Line in a CSV File</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290077#M63397</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm asking for help to solve this :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Example Input File&amp;nbsp; :&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Header;id_1;neg&lt;/P&gt;
&lt;P&gt;Detail;25&lt;/P&gt;
&lt;P&gt;Detail;20&lt;/P&gt;
&lt;P&gt;Header;id_2;neg&lt;/P&gt;
&lt;P&gt;Detail;10&lt;/P&gt;
&lt;P&gt;Detail;7&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Wanted Output File :&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;id_1;Header;id_1;neg&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;id_1&lt;/SPAN&gt;;Detail;25&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;id_1&lt;/SPAN&gt;;Detail;20&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;id_2&lt;/SPAN&gt;;Header;id_2;neg&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;id_2&lt;/SPAN&gt;;Detail;10&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;id_2&lt;/SPAN&gt;;Detail;7&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can see that the idea is to add a row id to make a link between Header lines and Detail lines&lt;/P&gt;
&lt;P&gt;I've tried with a tFileInputFullRow--&amp;gt;tMap--&amp;gt;tFileOutputCsv&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying with&amp;nbsp;keeping the Header id value in a global variable,&amp;nbsp;calling&amp;nbsp;it in an additional row in the tMap and change the value of this global variable for every next Header in the file....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But i failed to find a working way to do that&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 18:03:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290077#M63397</guid>
      <dc:creator>xrocq</dc:creator>
      <dc:date>2018-04-21T18:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Add row ID for Header and Line in a CSV File</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290078#M63398</link>
      <description>&lt;P&gt;1rst, use a tFileInputDelimited instead of a tFileInputFullRow and untick the option&amp;nbsp;&lt;SPAN&gt;"&lt;EM&gt;check each row structure against schema&lt;/EM&gt;".&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;Then you need to memorize the "id" each time a new "header" line is coming from the input flow.&lt;/P&gt; 
&lt;P&gt;You can achieve this&amp;nbsp;using a pair of tMap variables:&lt;/P&gt; 
&lt;UL&gt; 
 &lt;LI&gt;the 1rst one (called "id" in my example) get the value from the input row when the "header" field contains the keyword "header", else its value is got from the 2nd var called "lastId"&lt;/LI&gt; 
 &lt;LI&gt;after that, the value of the variable "lastId" is overwritten by the value of the variable "id"&lt;/LI&gt; 
&lt;/UL&gt; 
&lt;P&gt;Got it?&lt;/P&gt; 
&lt;P&gt;Here is how it looks like in the tMap:&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lwuv.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/140355i22AC1E871D3B05C0/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lwuv.png" alt="0683p000009Lwuv.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;And the result as expected:&lt;/P&gt; 
&lt;PRE&gt;[statistics] connecting to socket on port 3565
[statistics] connected
.----+------+----+---.
|     tLogRow_42     |
|=---+------+----+--=|
|id1 |header|id2 |neg|
|=---+------+----+--=|
|id_1|Header|id_1|neg|
|id_1|Detail|25  |   |
|id_1|Detail|20  |   |
|id_2|Header|id_2|neg|
|id_2|Detail|10  |   |
|id_2|Detail|7   |   |
'----+------+----+---'

[statistics] disconnected&lt;/PRE&gt; 
&lt;P&gt;Fianlly you just have to put the result into a tFileOutputDelimited without the header line and that's all.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 18:45:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290078#M63398</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2018-04-21T18:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Add row ID for Header and Line in a CSV File</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290079#M63399</link>
      <description>Did this help you?&lt;BR /&gt;If so, thank's to mark your case as solved (Kudo also accepted).</description>
      <pubDate>Sun, 22 Apr 2018 07:54:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290079#M63399</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2018-04-22T07:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Add row ID for Header and Line in a CSV File</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290080#M63400</link>
      <description>Sorry i was offline, i've just tried your solution now and its working perfectly ! 
&lt;BR /&gt; 
&lt;BR /&gt;I spent a long time with adding tJavas,tGlobalVars... for managing the id variables. 
&lt;BR /&gt;Because i didnt find how to use correctly the tMap Var part. 
&lt;BR /&gt; 
&lt;BR /&gt;Thanks a lot TRF, now i understand better the tMap Var part 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt;. 
&lt;BR /&gt; 
&lt;BR /&gt;You solution is very clean</description>
      <pubDate>Sun, 22 Apr 2018 09:22:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290080#M63400</guid>
      <dc:creator>xrocq</dc:creator>
      <dc:date>2018-04-22T09:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Add row ID for Header and Line in a CSV File</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290081#M63401</link>
      <description>&lt;P&gt;You're welcome&lt;/P&gt;</description>
      <pubDate>Sun, 22 Apr 2018 09:56:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Add-row-ID-for-Header-and-Line-in-a-CSV-File/m-p/2290081#M63401</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2018-04-22T09:56:52Z</dc:date>
    </item>
  </channel>
</rss>

