Import text as table with multiple delimiter as one

16 次查看(过去 30 天)
In want to import text from a logfile into a table with two columns. The delimiter should be '()'
Example:
T4 10:14:9 Class.Function() Patches were moved by 45.2206nm (max), 12.1091nm (mean)
Using the import-wizard and specifying the Column delimiters as custom and () everything works fine.
After some while i found a code-solution that works close to that what i want to have:
table = readtable(FilePath, 'Delimiter', '()' ,'MultipleDelimsAsOne',1);
But the problem is, that this delimits the text with the multiple delimiter AND the single delimiters as well, causing problems on the above example at (max) and (mean).
Are there some more sideconditions for readtable to prevent this? Thanks

采纳的回答

John Deer
John Deer 2018-7-17
I found out a solution on my own:
You have to specify the delimiter as a cell-array:
Delim = {'()'};
table = readtable(SourcePath, 'Delimiter', Delim ,'MultipleDelimsAsOne',1);

更多回答(0 个)

类别

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

产品

Community Treasure Hunt

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

Start Hunting!

Translated by