pythonmatlabnumpytextscan

Python equivalent of Matlab textscan


I'm working with transferring some Matlab code to Python. I'm relatively new to Python and am unsure of a Python equivalent of Matlab's textscan method. Any help would be greatly appreciated.


Solution

  • If you're translating Matlab to Python, I'll assume you're already using NumPy.

    In that case, you can use np.loadtxt (if no values are missing) or np.genfromtxt (if there are missing values: I'm not sure whether Matlab's textscan handles that).

    Give us a few more details if you need more help!