file as input for script

how do I use a file (comma seperated) as an input for a script in bin/sh?

e.g.

I have a script that :

Input1=$1
Input2=$2
Input3=$3
Input4=$4

echo "$Input1, $Input2, $Input3,$Input4" (or some other function)

If I have a .csv file which lists many rows of input:

joe,5,john,10
pat,77,tim,88
etc... (Input1,Input2,Input3,Input4)

How do I use this file for the input of what ever I make the script do? The input will be changed frequently, so I would like to just edit the .csv file, and have the script update the info.

Thanks

As long as the number of fields are fixed (and there is no

whitespace in the fields), a quick script like

 #!/bin/sh

 while read line
 do
   nocommas=`echo $line | tr ',' ' '`
   set -- $nocommas
   echo "$1 $2 $3 $4"
 done < foo.csv

should do the job

If there is whitespace, then use awk

#!/bin/sh

while read line
do
  set -- `echo $line | awk -vFS=',' '{print $1,$2,$3,$4}'`
  echo "$1 $2 $3 $4"
done < foo.csv

Cheers
ZB