The above code prints the column position of the input string DName (that is 1)
Now the problem is, the above code is working fine for the data that starts from 1st line in a tab delimited file, but it is not working for files where the data is starting from 2 or 3 rd row.
The sample data of my input file looks like:
ACCENT_INPUT
Pcode Dealer Name Comp INF Date Year
TN16 9BE Ambrose Fisher Ltd Franklin UK Mid Cap Fund A Inc GBP GB00B3ZGH246 5/31/2012 2012 (starts from 2nd row
TN16 9GF Baggette and Company Wealth Management Limited Templeton Global Bond A Mdis GBP H1 LU0316492692 5/31/2012 2012
Thanks
---------- Post updated at 08:45 AM ---------- Previous update was at 08:29 AM ----------
in the same way, plz let me know if it is possible to insert a dummy column (column has a header but no data) in nth position?
Thanks
---------- Post updated at 08:48 AM ---------- Previous update was at 08:45 AM ----------
The below code works for data starting from 1st row
You need a criteria to determine at which line your data start.
Since we do not know how your input files can look like (we only have few examples) we can't guess which generic rule should be chosen so that it would work for all the different input you can have.
Could we assume that your data always start at the first lines beginning with "TN" ?
There is no particular pattern for the data, it could be in any format and start at any row.
Is it possible to get the line number where the column header starts, atleast
Thanks
---------- Post updated at 09:26 AM ---------- Previous update was at 09:22 AM ----------
how about this?
nawk 'NR>1{print NR; exit}' input_file.txt
but the result is 2, whereas the data is starting from line 3