read data from a file and fitting data