尝试使用 textscan 加载数据时出现问题 [英] problem when trying to load data with textscan

查看:67
本文介绍了尝试使用 textscan 加载数据时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想加载一组包含变量类型字符串和浮点数的数据.但是当我在八度音阶中使用 textscan 时,我的数据不会加载.我得到了矩阵 1x6(我有 6 个特征),但是在这个矩阵中我得到了不包含任何内容的单元格(0x1 的单元格).我的代码:

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);

例如,当我尝试 data(1) 时:

when I for example try data(1):

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

>>

有我的套装

我的文件 ID 也不是 -1.

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.

推荐答案

不要使用 textscan.Textscan 很糟糕,只有在没有更好的方法可用的情况下尝试解析数据时才应该使用它.

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.

您的数据是标准的 csv 文件.只需使用 io 包中的 csv2cell.

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

这篇关于尝试使用 textscan 加载数据时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆