Using Python to replace MATLAB: how to import data?
Date: 2022-07-25 10:23:27
I want to use some Python libraries to replace MATLAB. How could I import Excel data in Python (for example using NumPy) to use them?
I don't know if Python is a credible alternative to MATLAB, but I want to try it. Is there a a tutorial?
Answers:
Depending on what kind of computations you are doing with MATLAB (and on which toolboxes you are using), Python could be a good alternative to MATLAB.
Python + NumPy + SciPy + Matplotlib are the right combination to start.
For the data, you can, for example, save your data directly in text file (assuming that you are not directly concerned by floating-point precision issues) and read it in Python.
If your data are Excel data, where each value is separated by a ";", you can for example read the file line by line, and use the split() method (with ";" as argument) to get each value.
For MATLAB up to version 7.1, it is possible to directly load .mat files from Python with the scipy.io.matlab.mio module.