Your approach is of course valid and should work when you are properly parsing the strings to classes.
Alternatively, you could also store the class indices directly in your structure.
Also, take a look at e.g. pandas which provide an easy way to store structured data.