How to check csv header names are valid

One Star

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?
Five Stars

Re: How to check csv header names are valid

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.
One Star

Re: How to check csv header names are valid

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
Five Stars

Re: How to check csv header names are valid

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
Seventeen Stars

Re: How to check csv header names are valid

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

Re: How to check csv header names are valid

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.
One Star

Re: How to check csv header names are valid

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
Five Stars

Re: How to check csv header names are valid

welcome..
Seventeen Stars

Re: How to check csv header names are valid

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
One Star

Re: How to check csv header names are valid

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.