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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
imholzj
Contributor III
Contributor III

Filter comments out of input file

I have a csv file that has leading comments, how can I filter them out?

 

# use this file for additional users
# all values must be present
id,userName,date
"1","foo","01.01.2019"
"2","bar","02.01.2019"
.
.
.
Labels (3)
1 Solution

Accepted Solutions
imholzj
Contributor III
Contributor III
Author

I'm going with a tFilterRow for a solution:

 

Advanced mode with:  

 

// filter out all comments
!( java.util.regex.Pattern.matches("^\\s*#.*", row1.Status) )

 

In this case "Status" is the first field defined in the schema (which happened to be String.)   I'm not sure how to do this if it weren't.

 

Thanks,

 

jji

View solution in original post

5 Replies
Anonymous
Not applicable

use Header = 2 in tfiledelimted

look at the screeshot below

0683p000009M3PR.png

akumar2301
Specialist II
Specialist II

 

If your 1st Field is Integer like "1" or 1(as in you case) ,  just remove "Die On Error" , All the record will be rejected( Including header)

You can capture these using Reject Link from Input Component

 

 

 

 

imholzj
Contributor III
Contributor III
Author

I am looking for a more general solution, allowing people to add more comments if necessary.  Seems like hardcoding a 2 would prevent that.

 

jji

imholzj
Contributor III
Contributor III
Author

I'm going with a tFilterRow for a solution:

 

Advanced mode with:  

 

// filter out all comments
!( java.util.regex.Pattern.matches("^\\s*#.*", row1.Status) )

 

In this case "Status" is the first field defined in the schema (which happened to be String.)   I'm not sure how to do this if it weren't.

 

Thanks,

 

jji

Anonymous
Not applicable

@imholzj but if the file is in below format

 

VERSION = 2007
DATE = 10/23/2017
EXPDATE = 10/1/2018
###########################################
FAMILY NURSE CARE OF LLC
HARRY GILL, MD, PHD, PC
LEAWOOD FAMILY EYE CARE PA

 

By using the tfilterrow in advance setting we can only remove one line with ## symbols

 

Please look at screenshot below i ran the test0683p000009M36D.png