func to parse training data