Matlab:使用textscan

时间:2015-05-21 22:08:52

标签: matlab

我正在尝试使用分号(;)分隔符加载csv文件。

示例:

150501;190722;ms_since_start=;30001276;temp=;31.97;IT=;147753;spec num=;1000;(here i have 512 floating number repetitions and ';;' to indicate the end of line) 

此模式重复1000行。

我一直在尝试使用文本扫描,但只使用以下代码获取空单元格

formatSpec = ['%s%s%*s%*s%*s%*s%*s%*s%*s%*s%*s' repmat('%f', [1,512]) '%*[^;;]']
M = textscan(dirtmp, formatSpec, 'Delimiter', ';')

目标是获得前2列,跳过9,获得剩余的512列,并重复1000行。

非常感谢任何帮助

1 个答案:

答案 0 :(得分:0)

看看这个问题的答案1。我认为你实际上不能跳过专栏,但是一旦得到输出你可以说:

x = read_mixed_csv('example.csv',';');
y = x{:, [1,2, 11:size(x, 2)]};