Help with appending to a csv file

I am working to import a file and have almost all the information accounted for except this last item. First of all the file name is the category and this is what I need to append to the file.

The catch I believe is the fact the file name has spaces in it.
Filename CPU Products.csv

File input:

code,description,weight,cost,price,qty,category
"A4552","Intel i7 4.60GHz Processor","0.53","250.00","350.00","10"

What I need is the following:

code,description,weight,cost,price,qty,category
"A4552","Intel i7 4.60GHz Processor","0.53","250.00","350.00","10","CPU Products"

Here is what I have:

file="CPU Products.csv"
tmpfile=csvfile.tmp
tmpfile1=csvfile1.tmp
category=`basename "$file" .csv`

        cp "$file" $tmpfile
        awk '
        BEGIN {FS=OFS=","; print "code,description,weight,cost,price,qty,category"}
        ($9= "$category") ' $tmpfile > $tmpfile1

        cp $tmpfile1 "$file"

Rather than appending "CPU Products" it puts $category as the last field.

Any help is very much appreciated.

Try:

awk '{f=FILENAME;sub("\.csv","",f);$0=$0",\""f"\""}1' "CPU Products.csv"

Hi,

Using 'perl':

$ perl -pe 'next if $. == 1; chomp; $ARGV =~ s/\.[^.]+$//; $_ .= qq[,"$ARGV"\n]' "CPU Products.csv"

Regards,
Birei

Thanks for your help!!!

The only problem is the category area has the extension on it and it has removed my header.