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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s