Converting rows to columns using shell script

I have a script which converts rows to columns.

file_name=$1
mailid=$2
#CREATE BACKUP OF ORIGINAL FILE
#cp ${file_name}.xlsx ${file_name}_temp.xlsx
#tr '\t' '|' < ${file_name}_temp.xlsx >  ${file_name}_temp.csv
#rm ${file_name}_temp.xlsx
pivot_row=`head -1 ${file_name}`
sed 1d ${file_name}>Sandeep
print "QUARTER\tMETRIC\tMETRIC_VALUE" > pivot_results.xlsx
#LOOP WHILE ROWS ARE LEFT
while IFS= read line
do
   counter=1
        curr_line=$line
        curr_metric=`echo $line | cut -f1 -d","`
        curr_value="dummy"
        #LOOP WHILE COLUMN VALUES FOR THE CURRENT ROW ARE NOT NULL
        while [[ $curr_value != "" ]];
        do
                ((counter=counter+1))
                curr_value=`echo $line | cut -f${counter} -d","`
                if [[ $curr_value != "" ]]; then
                        curr_pivot_value=`echo $pivot_row | cut -f${counter} -d","`
                        print "${curr_pivot_value}\t${curr_metric}\t${curr_value}" >> pivot_results.xlsx
                fi
        done
done < Sandeep
rm Sandeep
echo "Pivoting completed successfully!!"
uuencode pivot_results.xlsx pivot_results.xls | mailx -s PIVOT $mailid
echo "Result mailed to specified id!!"

for example the input is like this

1990    1991
kiran     201     202 
 

and the output should be like this

1990     kiran         201
1991     kiran         202
 
 

but iam getting the output as

1990    kiran        201
1991
           kiran        202

one column is going down.any body can help me.thanks in advance.

can you provide more samples?

If the input file is

1990    1991
kiran     201     202
andy     205     276

What's your expect output?

1990 kiran 201
1991 kiran 202
1990 andy 205
1991 andy 276

---------- Post updated at 07:19 PM ---------- Previous update was at 07:15 PM ----------

1990  kiran   201
1991  kiran   202
1990  andy   205 
1991  andy   276

How about this using awk:

awk '
  NR==1{ for(h=1;h<=NF;h++) R[h]=$h ; next }
  { for(v=2;v<=NF;v++) print R[v-1], $1, $v }
' infile

or in bash:

#!/bin/bash
while IFS= read line
do
    if [ -z "${R[0]}" ]
    then
        R=( $line )
    else
        C=( $line )
        v=1
        while [ $v -lt ${#C[@]} ]
        do
            echo ${R[v-1]} ${C[0]} ${C[v]}
            let v=v+1
        done
    fi
done < infile