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.