extracting data from a .csv file

I have a .csv file
equipment,bandtype
abc,aws
def,mmds
ghi,umts
jkl,mmds

I can get the equipment from `hostname`.
In my script i want to check what is the hostname. then see if it exists in the.csv file. if it does then i want to store the second parameter(bandtype) for the corresponding equipment(which comes from hostname) in a variable.

say my hostanem was abc. i want to check if abc exists in a file and if it does then i want to extract the second parameter(aws) and store it in a varibale

HOSTNAME=`hostname`
BANDTYPE=`grep "^${HOSTNAME}," filename.csv | awk -F"," '{ print $2 }'`

Where filename.csv is the name of your csv file, and the BANDTYPE variable contains the second parameter, will do what you are after.

Replace:
HOSTNAME=`hostname`
with:
HOSTNAME=$1
to search for a hostname handed into the script as a parameter.

it print a whitespace when i do echo $BANDTYPE.
This does'nt seem to work

it does work. thanks