Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Zurich on Sept 24th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to trim the last x lines of a text flat file?

I am new to Qlik, but trying to load flat files.  The files have a trailing section which is always the same height.  Is there any way to transform the data to do this programatically ?

9 Replies
shraddha_g
Partner - Master III
Partner - Master III

Can you share sample data and expected output?

maxgro
MVP
MVP

maybe

load the table and add a recno

X:

load

  recno() as id,

  rand() as field1,

  rand()*100 as field2

AutoGenerate 100;

discard the last 10 rows

Right Keep (X)

load *

Resident X

Where id <= NoOfRows('X') -10;

Anonymous
Not applicable
Author

Hi

following is for deleting last 2 rows of Excel or csv file

Let vNoOfColumns = NoOfFields('your table name');

ANS:

for i = 1 to nooffields('YourCSV')   // no of columns in excel file

if $(i) >= nooffields('YourCSV') - 2 then

let vFieldname = fieldname($(i), 'YourCSV');

drop field $(vFieldname);

end if

next

vinieme12
Champion III
Champion III

You can use the file transformation wizard

Below is an example showing how to remove the last three rows from a table load

Steps:

Enable Transformation Step(Appears after initial table load screen) >> Conditional Delete

delete last n rows.png

This will add this particular line to your From statement

FROM

(biff, embedded labels, table is Sheet1$, filters(

Remove(Row, RowCnd(Interval, Pos(Bottom, 1), Pos(Bottom, 3), Select(1, 0)))

));

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Anonymous
Not applicable
Author

wow, thanks for all the great advice. I will research this and try it out. The trailing text is

.

PSC

filename=attente

records=0000000000002

ldbname=futur

timestamp=2016/09/29-21:05:09

numformat=44,46

dateformat=dmy-1950

map=NO-MAP

cpstream=ISO8859-1

.

0000000098

This is data file information at the end, and I would avoid removing it.  I tried Merrant ODBC but I can't seem to configure the drivers to connect to the progress 4GL database .

maxgro
MVP
MVP

This is for Qlikview, don't think it exists in Sense and the question is in a Sense forum.

I think you can install Sense and Qlikview on the same pc, use the Qlikview transformation wizard to create the script and then copy to Sense script.

Anonymous
Not applicable
Author

I downloaded QlikView, figured out how to get to the transformation wizard.  I tried the transformation on a clients data file, the script looks like this:

Image 001.png

Only problem is that it says it fetched 8119 rows, yet the real # of records is 8107.  So is the Filter clause working?

In the app if I drop down the Client# column in a sheet, the data does not seem to have truncated the trailing part:

Image 002.png

lakshmikandh
Specialist II
Specialist II

Thanks Vineeth, This will work.

vinieme12
Champion III
Champion III

I don't think you will need to use the filter clause here, just use the where clause with data validation to filter only data rows.

WHERE  ISNUM(CLIENT#) = -1 ;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.