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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to check csv header names are valid

Hi,
I need to know if the csv file which is being processed has header names same as per expected.If the header names are different i need to reject the file.If the header names are same as per schema then the file is supposed to be processed.
Please advise how this can be done?
Labels (3)
9 Replies
Anonymous
Not applicable
Author

read a first row of the file using tFileInputFullRow component then check first row of the file with tJavaRow using string compare methods like "contains, equals, equals ignore case" and based on compared result you can process file or reject it.
Anonymous
Not applicable
Author

But how to check if the field names are as per expected tFileInputDelimited schema?Or are we supposed to check with hardcoded names?Also how to check only header names matches?And also if valid i want to process the file as tFileInputDelimited
Anonymous
Not applicable
Author

please design job as follows:
create boolean variable "result"
tFileInputFullRow----tJavaRow--tJava--if(false)--take action
|
If(True)
|
tFileInputDelimited
in tJavaRow use following code
------------------------------------------
context.result= line1.equalsIgnoreCase("col1,col2,col3");

in true If connector check variable value
-----------------------------------------------------
context.result==true

in False If connector check variable value
--------------------------------------------------------
context.result==false
Anonymous
Not applicable
Author

hi all,
have a lookt at "tSchemaComplianceCheck" that is designed for that goal.
regards
laurent
Anonymous
Not applicable
Author

if you have extra column at the end of header row then tSchemaComplianceCheckwill not reject your file as schema change, even it is work to reject rows not entire file.
Anonymous
Not applicable
Author

Hi umeshrakhe,
Thanks i was able to handle my conditions with your previous solution.
And yes tSchemaComplianceCheck does not work with extrat columns.Also it was not validating field names.
Thanks a lot,
anaya
Anonymous
Not applicable
Author

welcome..
Anonymous
Not applicable
Author

hi all,
for extra column, you can use a referentiel schema to check against it.
I use to work with referenced against built-in to work with the up-to-date schema in my job.
regards
laurent
Anonymous
Not applicable
Author

hi all,
have a lookt at "tSchemaComplianceCheck" that is designed for that goal.
regards
laurent

Hey Kzone,
As I know, tSchemaComplianceCheck can only used for below-
1. for max length
2. for date patterns
and can not used for column name validation.