problem when trying to load data with textscan

浪尽此生 提交于 2021-02-11 14:13:05

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/61415582/problem-when-trying-to-load-data-with-textscan

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!