You can read the contents of the "file" (or in this case, the input string) using the np.genfromtxt function (check out this stackoverflow answer for help with the dimensionality), and fit the data using np.linalg.lstsq.