我正在使用textread函数在Matlab中读取一个csv文件,并将值存储在string和float类型的单元格中。
[string1, string2, values] = textread('/path/xyz.csv', '%s %s %f', 'headerlines', 1);
数据有三列。我认为其中两个是字符串类型,一个是浮点数。
样本数据
@timestamp host value
March 5th 2019, 13:41:54.879 tscompute1 0.399
March 5th 2019, 13:41:54.879 tscompute1 0.599
March 5th 2019, 13:41:54.879 tscompute1 0
March 5th 2019, 13:41:54.879 tscompute1 0.2
March 5th 2019, 13:41:54.879 tscompute1 0
March 5th 2019, 13:41:54.879 tscompute1 0
March 5th 2019, 13:41:54.879 tscompute1 0
March 5th 2019, 13:41:54.879 tscompute1 0
March 5th 2019, 13:41:54.879 tscompute1 0
March 5th 2019, 13:41:54.879 tscompute1 100
March 5th 2019, 13:41:54.879 tscompute1 0.4
没有执行错误。但是读取值并不像预期的那样。请在下面找到示例输出。
存储在string1中的值如下所示
'"March'
','
'"March'
','
'"March'
','
'"March'
','
存储在string2中的值如下所示
'5th'
'13:41:54.879",tscompute1,0.399'
'5th'
'13:41:54.879",tscompute1,0.599'
'5th'
'13:41:54.879",tscompute1,0'
'5th'
'13:41:54.879",tscompute1,0.2'
存储在值中的值如下所示
2019
0
2019
0
2019
0
2019
0