Key word "nasty". A house can never be too clean, however, many buyers will rip out carpeting and install flooring of their choice. If it is truly nasty and dirty, then I would suggest professionally cleaning it. If you have a cleaning company give you an estimate, they should be able to tell you if it will or will not clean up nicely. If it is stained, replace it with an inexpensive carpeting. As I mentioned new owners will probably replace but it will show much better and that is really what your goal should be when trying to sell.
Best of luck.