Octave reads CSV into a single Row

Reading a CSV into Octave is fairly simple. You can use the following command to specify the filename, separator and the array to load the data into. Just make sure you don’t have any headers in the file otherwise Octave will create a row of zeros instead.

data = dlmread(“test.csv”, “,”);

But if you find that Octave is reading everything into a single row which is filled with gibberish, it’s probably an issue with the end of line (EOL) encoding. In my case, the CSV was encoded with a Mac EOL. Octave is comfortable only with Windows or Linux EOLs.

Converting is fairly easy. Open Notepad++ and select Edit->EOL Conversion->Windows Format or UNIX Format. That will fix the problem.

image

Advertisements