<?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: tFileOutputDelimited and that LAST row separator in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311459#M82495</link>
    <description>Assuming your file is like: 
&lt;BR /&gt;blablabla, 
&lt;BR /&gt;blablabla, 
&lt;BR /&gt;....., 
&lt;BR /&gt;blablablaba, 
&lt;BR /&gt;You could first use a tfilerowcount to get the number of rows and save it in a context variable like context.rowcount. Then you use a a tjava as an output of this file. You tjava is like this: 
&lt;BR /&gt; 
&lt;BR /&gt;String result=""; 
&lt;BR /&gt;int nb=0; 
&lt;BR /&gt;InputStream ips=new FileInputStream("C:\\YOURFILE.csv"); 
&lt;BR /&gt;InputStreamReader ipsr=new InputStreamReader(ips); 
&lt;BR /&gt;BufferedReader br=new BufferedReader(ipsr); 
&lt;BR /&gt;String ligne; 
&lt;BR /&gt;while ((ligne=br.readLine())!=null){ 
&lt;BR /&gt; nb++; 
&lt;BR /&gt; if(nb==context.rowcount) 
&lt;BR /&gt; result=ligne.remplace(',',''); 
&lt;BR /&gt; result+=ligne+"\n"; 
&lt;BR /&gt;} 
&lt;BR /&gt;br.close(); 
&lt;BR /&gt;globalMap.put("mailBody", mailBody); 
&lt;BR /&gt;Then you put the result string in a context variable and you use it to put it in a file. (I didn't try it but I think it could work).</description>
    <pubDate>Tue, 08 Nov 2011 13:26:27 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-11-08T13:26:27Z</dc:date>
    <item>
      <title>tFileOutputDelimited and that LAST row separator</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311452#M82488</link>
      <description>Hello: 
&lt;BR /&gt;I am taking a 1-column data flow and outputting it to a file using tFileOutputDelimited to create JSON files. I'm using ",\n" as the Row Separator, and it works great. 
&lt;BR /&gt;Except for the last row, which always has that annoying last "," on the end. I haven't found any way to remove it either, aside from editing the file output and removing it manually. 
&lt;BR /&gt;Anyone have any ideas, either using Talend components or maybe some java?
&lt;BR /&gt;Thanks...</description>
      <pubDate>Sat, 16 Nov 2024 12:35:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311452#M82488</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T12:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: tFileOutputDelimited and that LAST row separator</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311453#M82489</link>
      <description>Hi 
&lt;BR /&gt;You could read each row from the file using tFileInputFullRow, and then remove the last common "," if it has, output the whole row to a final file. 
&lt;BR /&gt;Best regards 
&lt;BR /&gt;Shong</description>
      <pubDate>Mon, 07 Nov 2011 05:55:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311453#M82489</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-11-07T05:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: tFileOutputDelimited and that LAST row separator</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311454#M82490</link>
      <description>Great idea - except: how would I know which row is the last one? See, all of the rows end in "," 
&lt;BR /&gt;Unless maybe there's a way to read in the entire file and remove all the "\n" characters so that the entire thing can be addressed in a tMap component, where the last character can be snipped off? 
&lt;BR /&gt;Or am I misunderstanding totally (the more likely case &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 07 Nov 2011 13:26:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311454#M82490</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-11-07T13:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: tFileOutputDelimited and that LAST row separator</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311455#M82491</link>
      <description>Hi,&lt;BR /&gt;Maybe you could use the lastIndexOf methode of the String object and then make a substring?</description>
      <pubDate>Mon, 07 Nov 2011 14:18:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311455#M82491</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-11-07T14:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: tFileOutputDelimited and that LAST row separator</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311456#M82492</link>
      <description>assuming that I get the file into one long string I think that would work. But some of these files can get to be very large. There must be a better way ...</description>
      <pubDate>Mon, 07 Nov 2011 17:15:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311456#M82492</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-11-07T17:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: tFileOutputDelimited and that LAST row separator</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311457#M82493</link>
      <description>Hi
&lt;BR /&gt;It always read the whole content of file, the efficiency could be slow if the file is very large, I don't know the details about how do you generate the file, maybe you should consider the solution during the file generating...
&lt;BR /&gt;Best regards
&lt;BR /&gt;Shong</description>
      <pubDate>Tue, 08 Nov 2011 03:34:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311457#M82493</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-11-08T03:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: tFileOutputDelimited and that LAST row separator</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311458#M82494</link>
      <description>Hi,&lt;BR /&gt;Have you considered using tFileOutputJSON?  Here's a simple 2-component blog post on producing a JSON file from a single data flow.&lt;BR /&gt;&lt;A href="http://bekwam.blogspot.com/2011/01/text-file-to-json-with-talend-open.html" rel="nofollow noopener noreferrer"&gt;http://bekwam.blogspot.com/2011/01/text-file-to-json-with-talend-open.html&lt;/A&gt;</description>
      <pubDate>Tue, 08 Nov 2011 11:56:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311458#M82494</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-11-08T11:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: tFileOutputDelimited and that LAST row separator</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311459#M82495</link>
      <description>Assuming your file is like: 
&lt;BR /&gt;blablabla, 
&lt;BR /&gt;blablabla, 
&lt;BR /&gt;....., 
&lt;BR /&gt;blablablaba, 
&lt;BR /&gt;You could first use a tfilerowcount to get the number of rows and save it in a context variable like context.rowcount. Then you use a a tjava as an output of this file. You tjava is like this: 
&lt;BR /&gt; 
&lt;BR /&gt;String result=""; 
&lt;BR /&gt;int nb=0; 
&lt;BR /&gt;InputStream ips=new FileInputStream("C:\\YOURFILE.csv"); 
&lt;BR /&gt;InputStreamReader ipsr=new InputStreamReader(ips); 
&lt;BR /&gt;BufferedReader br=new BufferedReader(ipsr); 
&lt;BR /&gt;String ligne; 
&lt;BR /&gt;while ((ligne=br.readLine())!=null){ 
&lt;BR /&gt; nb++; 
&lt;BR /&gt; if(nb==context.rowcount) 
&lt;BR /&gt; result=ligne.remplace(',',''); 
&lt;BR /&gt; result+=ligne+"\n"; 
&lt;BR /&gt;} 
&lt;BR /&gt;br.close(); 
&lt;BR /&gt;globalMap.put("mailBody", mailBody); 
&lt;BR /&gt;Then you put the result string in a context variable and you use it to put it in a file. (I didn't try it but I think it could work).</description>
      <pubDate>Tue, 08 Nov 2011 13:26:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tFileOutputDelimited-and-that-LAST-row-separator/m-p/2311459#M82495</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-11-08T13:26:27Z</dc:date>
    </item>
  </channel>
</rss>

