Name Anonymization Software
You have a few problems here.  The first is cleaning your data.  That's a whole separate issue form anonymization and belongs in another question if you're still having problems with it.

The second is your anonymization.  After you have some sort of identifier you're satisfied with (sounds like you're using people's real names), try hashing their names to generate a new id.  This id is useful because you'll always be able to take the original name and figure out what id it is but won't be able to derive the real names from just the hashed id (providing your hashing algorithm is good).

Further reading:


https://security.stackexchange.com/a/61878
https://stackoverflow.com/a/21563966/4435034