Assuming there will never be commas in your original data, you should be able to use the following:
:%s/.*/\L\0\E,"\0"/ | %s/ \([^,]*,\)\@=/_/g
This just does another replacement after your current one to replace all of the spaces that come before a comma (using a positive lookahead).