BEGIN{
# Put your column widths below.
numcols = split("9 5 12 20",widths)
}
{ start = 1
for (i=1; i<= numcols; i++)
{ printf "%s", csv(substr($0,start,widths[i]))
printf "%s", ( i<numcols ? "," : "\n" )
start += widths[i]
}
}
function csv(s)
{ # Double any double quotes.
gsub( /"/, "&&", s )
return "\"" s "\""
}