Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to Check if the order of columns in two files is same?

I have two files containing columns names ,I need to validate if the columns are in the same order.

 

For eg : File1

ID;Name;Address

File2

ID:Address:Name

 

If these are the input files.I should be able to extract the columns which are in the wrong order.

Labels (2)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

If you don't need to identify all the differences but just check if both header lines are identical, I suggest you to extract them and concatenate the values into a single string for each file giving something like "field1;field2;field3" for the 1rst file and maybe something like "field1;field3;field2" for the 2nd file. Then you can compare the strings.

View solution in original post

20 Replies
TRF
Champion II
Champion II

Use tFileInputFullRow with Limit=1 to get header line from yours input files.

Then use String.equals() or String.equalsIgnoreCase() methods to compare both header lines.

If they don't match, order is not the same or column names are different. 

TRF
Champion II
Champion II

Use tFileInputFullRow with Limit=1 to get header line from yours input files.

Then use String.equals() or String.equalsIgnoreCase() methods to compare both header lines.

If they don't match, order is not the same or column names are different. 

Anonymous
Not applicable
Author

I also have a excel source file and tfileinputrow is not reading it properly any other option for reading excels?

Anonymous
Not applicable
Author

I also have a excel source file and tfileinputrow is not reading it properly any other option for reading excels?

TRF
Champion II
Champion II

No, this is for simple text files.
For Excel files, if you have a header line, you must do it by yourself.
TRF
Champion II
Champion II

No, this is for simple text files.
For Excel files, if you have a header line, you must do it by yourself.
Anonymous
Not applicable
Author

So i should extract the header row of the two excels separately then compare them in a tmap right?
Anonymous
Not applicable
Author

So i should extract the header row of the two excels separately then compare them in a tmap right?
TRF
Champion II
Champion II

If you don't need to identify all the differences but just check if both header lines are identical, I suggest you to extract them and concatenate the values into a single string for each file giving something like "field1;field2;field3" for the 1rst file and maybe something like "field1;field3;field2" for the 2nd file. Then you can compare the strings.