Comparing Column Headers

I have a csv file that I am loading into a datatable to process. Before processing, I want to verify the column headers against a template I will have stored. I see lots of ways for comparing Excel files / datatables but I just want to verify the headers of the incoming csv first to make sure nothing has changed and blows up my automated process. Any simple solution?

Appreciate any help! Thanks

you can have look at this post
cheers @Chris_Livesay

1 Like

That looks like it’s comparing column count which is ok but I need to make sure that the column names themselves match up. Thanks for the link. I did run the process.

Hi @Chris_Livesay if u want in more simple way u can use read range without add headers checked and check both datatable headers is equal or not inside the loop.

Do I need to have a loop if I want to just read and compare the first row?

I guess I don’t have to have a template, I could simply have a header string in the Config file and then compare the DT header with that string in the config. The challenge is how do I get the DT header row into a string to compare? Am I thinking about this correctly?

No u dont need to loop u can simply compare them with this dt1.Columns(0).ToString=dt2.Columns(0).ToString

1 Like

If U have your template in excel or csv its still fine we can compare it.

You world read both tables and then You can write a simple stored procedure to execute as in below:

Short and to the point! Thank you @Tushar_Karkera , exactly what I was looking for.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.