Simple and easy way to count the columns in cvs files in Linux using sed utility.
Ous csv file is called data.csv and contains the following
1,1,1
2,2,2
3,3,3
[dbadmin@hosttmp]$ head -1 /tmp/data.csv
1,1,1
-- use sed utility
[dbadmin@hosttmp]$ head -1 /tmp/data.csv | sed 's/[^,]//g'| wc -c
3
-- use sed utility
[dbadmin@host tmp]$ head -1 /path/to/file.csv | awk -F, '{print NF}'
3