Listing contents of fields

I am often given log files at work in .csv format to work with, normally extracting various fields. I then have to figure out the number of each field so that I can extract that field with cut or awk. Normally I just manually count the fields, based on the field separator. I would like to be able to take a line from the file and list the contents of each field along with the number of a field. Thus having the line of a file, such as:

apples,oranges,lemons,pears,peaches

I would like to see the output as:

1 apples
2 oranges
3 lemons
4 pears
5 peaches

I can then quickly see the columns that I need to extract.

I am aware of the "column" command, but often the files I have contain too many columns for this command to work.

Any help would be much appreciated

Welcome to the forum.

Any idea on how to solve that with awk ?

My awk-fu isn't so good. I guess it would need something like

awk 'BEGIN { FS = ","}' myfile.csv

But not sure how to print each field on a separate line along with the field number.

Try

awk -F, '{for (i=1; i<=NF; i++) print i, $i}' file
1 apples
2 oranges
3 lemons
4 pears
5 peaches
1 Like