generic method for reading data files