Go to the dashboard>tools>export menu. Once there, do an export. If I understand how WordPress does these, it will export only the parts you need to keep your posts, comments etc.
After that, you can re-install WordPress.
A couple more notes:
1. If you were infected, it is very likely your theme was infected. You may have to start with a clean theme.
2. You may have infected files in your wp-content, plugins and uploads folders. When you reinstall, replace all your plugins with new ones. Also, go through your uploads folder and look for suspicious files in there.
I was infected quite badly and was able to clean things up and recover. Good luck. :)