Search code examples
octavetextscan

problem when trying to load data with textscan


I want to load a set of data that contains variables type string and float. But when I use textscan in octave, my data doesn't load. I got matrix 1x6 (i have 6 features), but in this matrix I got cells that contains nothing(cells that are 0x1). my code:

filename='data1.txt';
fileID = fopen(filename,'r');
data = textscan(fileID,'%f %s %s %f %f %s','Delimiter',',');
fclose(fileID);

when I for example try data(1):

 >> data(1)
ans =
{
  [1,1] = [](0x1)
}

>>

there is it

there is my set

Also my file id isn't -1.

I had been searching for in the ethernet problem like this but I couldn't find any. I tried to delete headers in data and smaller training set but it don't work. Pls help.


Solution

  • Don't use textscan. Textscan is horrible, and one should only use it when they're trying to parse data when there's no better way available.

    Your data is a standard csv file. Just use csv2cell from the io package.