Subsections

Importing data

Space/Tab/Comma separated data

Numpy has a very handy import function for data as long as the the elements in the data file are separated with spaces, tabs or commas. To load such data files just type in: x = np.loadtxt('mydatafile.dat'). This creates a two dimensional array which reflects exactly the structure in the datafile.

Thus, if you want to write software which creates Python readable data then just export the data as space/tab separated ASCII files.

WAV files

Scipy contains in its submodule io a subsubmodule wavfile which supports reading and writing wav files:
import scipy.io.wavfile as wavfile
fs,data = wavfile.read('kongas.wav');
fs,data is a tuple containing the sampling rate and then the data.

import scipy.io.wavfile as wavfile
wavfile.write('kongas_filt.wav',fs,y3);
whereas 'fs' is the sampling rate and y3 the data – usually normalised between -1 and +1 for floating point numbers.



github / contact

Creative Commons License