preprocessing for both training file and test file