Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
raju_insights
Partner - Creator III
Partner - Creator III

How to avoid blank line at the end in txt file when storing a table as txt file from QlikSense?

Hello everyone,

When storing a table from Qlik Sense as a txt file, there is always a blank line at the end of the txt file. How to avoid that blank line?

Please let me know is there a direct solution or can it be achieved by a workaround?

 

Thanks

Labels (2)
1 Solution

Accepted Solutions
raju_insights
Partner - Creator III
Partner - Creator III
Author

Hi @qv_testing , @marcus_sommer ,

I achieved the desired output by executing the following power shell script from qlik script:

Execute powershell [System.IO.File]::WriteAllText('test.txt', ((Get-Content 'test.txt' -Raw) -replace '\r?\n$'))

View solution in original post

7 Replies
qv_testing
Specialist II
Specialist II

I think you have null records in data.

use this condition in script:

Where LEN(ID_Field)>0

raju_insights
Partner - Creator III
Partner - Creator III
Author

Hi @qv_testing , there are no null records.

For example, try this 

Test:

Load * Inline [

ID, DIM

1, A

2, B

3, C

4, D

5, E

6, F

7, G

8, H

9, I

10, J

11, K

12, L

13, M

14, N

15, O

];

Store Test into [filepath/test.txt](txt);

Open the generated test.txt file and see. There will be a blank line at the end of the txt file. How to avoid that?

qv_testing
Specialist II
Specialist II

I feel that is not exactly the blank record - if you load back to qlik nothing is blank.

raju_insights
Partner - Creator III
Partner - Creator III
Author

Hi @qv_testing , yeah that is true if you load back. But the output txt file should not have that blank line. The requirement from the user is to avoid that blank line in the txt file. 

Is there a way to avoid that blank line at the end of the file?

 

marcus_sommer

There is not really an empty line else the last char of the last record is a line-break. Many viewer-tools and import-logic make from it a new empty line.

I doubt that there are any possibilities to adjust this behaviour during the export because it's a "feature" of used library.

In many cases it's not too hard to adjust the target-system to skip this empty line. A workaround to it might be to add a single EOF to the last field-value of the last field before the store is performed, maybe something like:

concatenate(MyTable) load chr(4) as LastField autogenerate 1;

The last char will be probably remain the line-break but most import-logic are stopping the read-process if there is any EOF included.

If nothing of the above is working or practically you will need an external batch to adjust the file.

raju_insights
Partner - Creator III
Partner - Creator III
Author

Thanks @marcus_sommer , I will try that.

raju_insights
Partner - Creator III
Partner - Creator III
Author

Hi @qv_testing , @marcus_sommer ,

I achieved the desired output by executing the following power shell script from qlik script:

Execute powershell [System.IO.File]::WriteAllText('test.txt', ((Get-Content 'test.txt' -Raw) -replace '\r?\n$'))