You can use a data cleansing tool and set the configuration "Remove unwanted characters - Leading and Trailing spaces" as checked.
Also, you can use a formula tool and use the function Trim()
To convert it to upper case, use the formula Uppercase(), like Uppercase(C4)
Use a " If " statement for processing conditions.
You can refer the attachment too.