当分隔符在一个字段中时,在Matlab中的textscan和什么可以忽略“字符 [英] textscan in Matlab when delimiter is in a field and what to ignore " character
本文介绍了当分隔符在一个字段中时,在Matlab中的textscan和什么可以忽略“字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
pre $
1234 ,24.0,你好,我叫乔
4567,25,0,你好,我是简
第三个字段中的非分隔逗号是有问题的,我最终不希望围绕
我已经尝试了下面的内容,但是在最后一个字段的末尾留下了一个字符,我可以删除这个方法,但是我发现它很烦人,肯定有一个更聪明的方法。任何想法?
textscan(fileId,'%s%s使用<$ c $,$'$','' c>%s
for formatSpec的最后部分看起来很自然,但是不起作用。您可以这样做
textscan(fileID,'%q,%q,%q','Delimiter', '\\\
');
Using textscan I'm trying to read a file that has comma separated data in the following format:
"1234","24.0","Hello, my name is Joe" "4567","25,0","Hi, I'm Jane"
The non-delimiter comma in the third field are problematic and I ultimately don't want the
""
around the pieces of data.I've tried the following, but it leaves a " on the end of the last field. I can remove this any number of ways, but I find it quite annoying and am sure there is a smarter way. Any ideas?
textscan(fileId, '"%s %s %s', 'Delimiter', {'","'})
Using
%s"
for the last part of the formatSpec seems natural, but isn't working.解决方案you could do this
textscan(fileID,'%q,%q,%q','Delimiter','\n');
这篇关于当分隔符在一个字段中时,在Matlab中的textscan和什么可以忽略“字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文