Listing column names in CSV file

Hi,

I have a .csv file that has ~600 columns and thousands of rows. I would like to create a numerical list of the column names (so that I can later easily select the columns I want to extract). The format that I would hope for is something like:

1   "ID"
2   "X" 
3   "Y" 
..
600 "Z"
 

I have tried various sed / awk commands that I have found online, but nothing has really produced what I need.. I know this is very basic, but would be very grateful for your help. Thank you.

Please show us (some of) your attempts!

Here is the command that I thought was most promising:

awk 'BEGIN{ FS="|" }
       { for(fn=1;fn<=NF;fn++) {print fn" = "$fn;}; exit; }
      ' filename.csv

But all I got was:

1 = "column1name", "column2name", "column3name", etc.

Rather than:

1 = "column1name"
2  = "column2name"

... etc, which is what I am after.

Any ideas?

So the columns seem to be separated by commas, not pipes. How about setting the field separator FS="," ?

Silly me. That now works.
Thank you very much for your help.
AB