loading data from a CSV file
We are now going to use the Numerical Python (numpy) command loadtxt
to load data from this CSV text file. Each column of data will become a Numerical Python (numpy
) array.
The process consists of two steps:
- importing the
loadtxt
command from Numerical Python - using the
loadtxt
command to transfer the data from the file
importing commands
loadtxt
is not part of the core Python language but is instead part of the Numerical Python package (numpy
). We must therefore "import" into our program before using. There are two common methods of doing this.
In the first method, each individual function or module (such as loadtxt
from numpy
) is imported as needed . We call this the direct numpy import style.