Multiple delimiters for readtable

36 次查看(过去 30 天)
Hello,
the data is stored in a text file like this:
Nb11(tab)Nb12 + Nb13 Nb14 + Nb15 Nb16 + Nb17
Nb21(tab)Nb22 + Nb23 Nb24 + Nb25 Nb26 + Nb27
I've tried to use the readtable command:
t = readtable('data.txt','Delimiter','tab +', MultipleDelimsAsOne, true)
and I obtain 4 columns instead of 7:
Nb11Nb12 Nb13Nb14 Nb15Nb16 Nb17
Do you have any suggestions in order to obtain 7 columns?
Thanks

采纳的回答

Star Strider
Star Strider 2019-6-11
To specify more than one delimiter, use a cell array of character vectors:
t = readtable('data.txt','Delimiter',{'tab', '+'}, MultipleDelimsAsOne, true)
  2 个评论
Pareil
Pareil 2019-6-11
Thanks for the reply, it works.
However, 'tab' is not taken into account when there are more delimiters, works fine by replacing it by '\t'.
Star Strider
Star Strider 2019-6-11
As always, my pleasure.
I always use the character string designations, such as '\t', for the delimiters.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by