Help with Parsing a CSV File

Hello All,

I have an input CSV file like below, where first row data can be in different position after every run of the tool, i.e. pzTest in below example is in column 1, but it can be also in 3 column and same for all the headers in the first row.

pzTest, pzExtract, pxUpdate, pzInfo
CR-1, "Administrator@TEST",	 "1",	"ExractToCSV"

I want to search for the position of Substring pzTest and pzInfo in String pzTest, pzExtract, pxUpdate, pzInfo and extract the column info pragmatically.For example pzTest should return 0 and pzInfo should return 3.

This is what i have:
grep "pzTest" TestFile.csv | awk '{print index($0,"pzTest")}'

But it does not help if i try to search other string in CSV.

Regards,
Adi

Try the awk script below...

awk -F, '{for(i=1;i<=NF;i++) if($i ~ "^ *(pzTest|pzInfo)$") print i-1}' TestFile.csv