<?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: How to Empty a files data after the load is completed in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328554#M97827</link>
    <description>&lt;P&gt;&lt;A href="https://community.qlik.com/s/profile/0053p000007LOStAAO"&gt;@ravi777&lt;/A&gt;&amp;nbsp;- if you want a java solution to handle excel files then you can write a routine and invoke that in your talend job something like this -&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JavaRoutine-1.JPG" style="width: 523px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lys4.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139669i2BD22ACEAEAE8E70/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lys4.jpg" alt="0683p000009Lys4.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;And, you can use below code to check and delete all rows from your excel file -&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;FileInputStream ExcelFileToRead = new FileInputStream(filePath);
XSSFWorkbook workbook = new XSSFWorkbook(ExcelFileToRead);
Sheet sheet = workbook.getSheetAt(0);
String sheetName = sheet.getSheetName();
int numberOfRows = sheet.getPhysicalNumberOfRows();
if(numberOfRows &amp;gt; 0) {
		for (int index = sheet.getLastRowNum(); index &amp;gt;= sheet.getFirstRowNum(); index--) {
		//System.out.println(index);
		if(sheet.getRow(index) != null) {
		sheet.removeRow( sheet.getRow(index));
		}
		else{
		    System.out.println("Info: clean sheet");
		}&lt;BR /&gt;             }
	}
ExcelFileToRead.close();  
// Write the output to the file
FileOutputStream ExcelFileToWrite = new FileOutputStream(filePath);
workbook.write(ExcelFileToWrite);
ExcelFileToWrite.close();  
&lt;BR /&gt;// Closing the workbook
workbook.close();
}&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jul 2018 12:30:32 GMT</pubDate>
    <dc:creator>iamabhishek</dc:creator>
    <dc:date>2018-07-05T12:30:32Z</dc:date>
    <item>
      <title>How to Empty a files data after the load is completed</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328547#M97820</link>
      <description>&lt;P&gt;Requirement is:&lt;/P&gt;&lt;P&gt;Tfileinputexcel ----&amp;gt; Tfileoutputexcel&amp;nbsp; ------&amp;gt; after loading into the output. i want to empty the inputexcel file without deleting the file.&lt;/P&gt;&lt;P&gt;How to achieve this.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 07:30:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328547#M97820</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-07-02T07:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to Empty a files data after the load is completed</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328548#M97821</link>
      <description>count number of rows and fill them with null or blank.
&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Jul 2018 07:36:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328548#M97821</guid>
      <dc:creator>fdenis</dc:creator>
      <dc:date>2018-07-02T07:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Empty a files data after the load is completed</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328549#M97822</link>
      <description>&lt;P&gt;&lt;A href="https://community.qlik.com/s/profile/0053p000007LKj7AAG"&gt;@TRF&lt;/A&gt;&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/0053p000007LKpMAAW"&gt;@fdenis&lt;/A&gt;&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/0053p000007LKmJAAW"&gt;@manodwhb&lt;/A&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Can you explain me&amp;nbsp;in steps.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 09:56:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328549#M97822</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-07-02T09:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to Empty a files data after the load is completed</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328550#M97823</link>
      <description>&lt;P&gt;&lt;A href="https://community.qlik.com/s/profile/0053p000007LOStAAO"&gt;@ravi777&lt;/A&gt;,Once the file has loaded and then take on subjob ok and delete the existing file or archive the file and create a new file as similar with your source file columns.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 12:26:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328550#M97823</guid>
      <dc:creator>manodwhb</dc:creator>
      <dc:date>2018-07-02T12:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Empty a files data after the load is completed</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328551#M97824</link>
      <description>&lt;P&gt;But when i am creating new .xlsx file using tfiletouch. it is creating but not able to open it.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 12:53:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328551#M97824</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-07-02T12:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Empty a files data after the load is completed</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328552#M97825</link>
      <description>tfiletouch create an empty file not an xlsx one</description>
      <pubDate>Mon, 02 Jul 2018 12:55:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328552#M97825</guid>
      <dc:creator>fdenis</dc:creator>
      <dc:date>2018-07-02T12:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to Empty a files data after the load is completed</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328553#M97826</link>
      <description>&lt;P&gt;&lt;A href="https://community.qlik.com/s/profile/0053p000007LOStAAO"&gt;@ravi777&lt;/A&gt;,you need to create with below way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tFilxedInputFlow--&amp;gt;tFileExceloutput&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 13:01:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328553#M97826</guid>
      <dc:creator>manodwhb</dc:creator>
      <dc:date>2018-07-02T13:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to Empty a files data after the load is completed</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328554#M97827</link>
      <description>&lt;P&gt;&lt;A href="https://community.qlik.com/s/profile/0053p000007LOStAAO"&gt;@ravi777&lt;/A&gt;&amp;nbsp;- if you want a java solution to handle excel files then you can write a routine and invoke that in your talend job something like this -&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JavaRoutine-1.JPG" style="width: 523px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lys4.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139669i2BD22ACEAEAE8E70/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lys4.jpg" alt="0683p000009Lys4.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;And, you can use below code to check and delete all rows from your excel file -&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;FileInputStream ExcelFileToRead = new FileInputStream(filePath);
XSSFWorkbook workbook = new XSSFWorkbook(ExcelFileToRead);
Sheet sheet = workbook.getSheetAt(0);
String sheetName = sheet.getSheetName();
int numberOfRows = sheet.getPhysicalNumberOfRows();
if(numberOfRows &amp;gt; 0) {
		for (int index = sheet.getLastRowNum(); index &amp;gt;= sheet.getFirstRowNum(); index--) {
		//System.out.println(index);
		if(sheet.getRow(index) != null) {
		sheet.removeRow( sheet.getRow(index));
		}
		else{
		    System.out.println("Info: clean sheet");
		}&lt;BR /&gt;             }
	}
ExcelFileToRead.close();  
// Write the output to the file
FileOutputStream ExcelFileToWrite = new FileOutputStream(filePath);
workbook.write(ExcelFileToWrite);
ExcelFileToWrite.close();  
&lt;BR /&gt;// Closing the workbook
workbook.close();
}&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 12:30:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328554#M97827</guid>
      <dc:creator>iamabhishek</dc:creator>
      <dc:date>2018-07-05T12:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to Empty a files data after the load is completed</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328555#M97828</link>
      <description>&lt;P&gt;Hello ravi777,&lt;/P&gt; 
&lt;P&gt;Is there any update for your issue?&lt;/P&gt; 
&lt;P&gt;Best regards&lt;/P&gt; 
&lt;P&gt;Sabrina&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2018 06:08:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328555#M97828</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-01T06:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Empty a files data after the load is completed</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328556#M97829</link>
      <description>&lt;P&gt;Thank you very much, very useful. &lt;/P&gt;&lt;P&gt;Just 2 comments to help here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1- Just in case, you need to add the following in your tJava component under Advanced setting  -&amp;gt; import&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import java.io.FileOutputStream;&lt;/P&gt;&lt;P&gt;import java.io.FileInputStream;&lt;/P&gt;&lt;P&gt;import org.apache.poi.xssf.usermodel.XSSFWorkbook;&lt;/P&gt;&lt;P&gt;import org.apache.poi.xssf.usermodel.XSSFSheet;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2- Sheet must be replaced by  XSSFSheet in the code &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3- there is an extra } at the end of the code that need to be removed&lt;/P&gt;&lt;P&gt;here is the corrected code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* start */&lt;/P&gt;&lt;P&gt;FileInputStream ExcelFileToRead = new FileInputStream(context.filePath);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;XSSFWorkbook workbook = new XSSFWorkbook(ExcelFileToRead);&lt;/P&gt;&lt;P&gt;XSSFSheet sheet = workbook.getSheetAt(0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String sheetName = sheet.getSheetName();&lt;/P&gt;&lt;P&gt;int numberOfRows = sheet.getPhysicalNumberOfRows();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if(numberOfRows &amp;gt; 0) {&lt;/P&gt;&lt;P&gt;	for (int index = sheet.getLastRowNum(); index &amp;gt;= sheet.getFirstRowNum(); index--) {&lt;/P&gt;&lt;P&gt;	//System.out.println(index);&lt;/P&gt;&lt;P&gt;		if(sheet.getRow(index) != null) {&lt;/P&gt;&lt;P&gt;		sheet.removeRow( sheet.getRow(index));&lt;/P&gt;&lt;P&gt;		}&lt;/P&gt;&lt;P&gt;		else{&lt;/P&gt;&lt;P&gt;		System.out.println("Info: clean sheet");&lt;/P&gt;&lt;P&gt;		}&lt;/P&gt;&lt;P&gt;	}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ExcelFileToRead.close();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Write the output to the file&lt;/P&gt;&lt;P&gt;FileOutputStream ExcelFileToWrite = new FileOutputStream(context.filePath);&lt;/P&gt;&lt;P&gt;workbook.write(ExcelFileToWrite);&lt;/P&gt;&lt;P&gt;ExcelFileToWrite.close();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Closing the workbook&lt;/P&gt;&lt;P&gt;workbook.close();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* end */&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 18:23:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-Empty-a-files-data-after-the-load-is-completed/m-p/2328556#M97829</guid>
      <dc:creator>AIjel</dc:creator>
      <dc:date>2021-01-07T18:23:31Z</dc:date>
    </item>
  </channel>
</rss>

