Quote:
Originally Posted by
nightrider
...
What if I don't know beforehand the columns that were missing? Will your code still work? ...
No, it won't. The posted code -
(a) adds an "ID" column in front of first column
(b) adds an "Email" column right before the 3rd column
Since it performs simple substitution and does not check for column headers specifically, you'd have two "ID" columns if your first column actually happens to be an "ID" column !
Quote:
...
I was using for loop in my earlier posting to perform a column header name matching to try to find out 1) the missing column ( as this is not fixed)
2) the position of the column if it matches...
The fact that you
do not know what all columns could be missing is most significant and it makes your problem much more difficult.
Here's what I think -
(a) Firstly, you will have to know your "desired" column headers. You won't know what's missing unless you have a complete list for comparison.
(b) Secondly, there's a question about "gaps" as well as "order". Let's say your desired column header is "c1,c2,c3,c4,c5" and your file has "c1,c3,c5". The missing columns over here are "c2,c4", but your file still has columns
in order.
Now, how do you want to handle the case when your file has columns "c4,c3,c1" ? There are missing columns, but the existing columns are out of order as well. Is this possible at all ? Do you want to change that to your "desired" order - i.e. fill the gaps as well as reorder ?
tyler_durden