Why does a table created using readtable have text values delimited by single quote where as table created using import have text values delimited by double quote?
2 次查看(过去 30 天)
显示 更早的评论
I have table UnitedNations created by opening UnitedNations.xlsx and selecting Import Selecton.

I also have table un created by
un = readtable("UnitedNations.xlsx")

Why is the first column in the UnitedNations variable delimited by double quotes when the first column in the un variable is delimited by single quotes?
0 个评论
采纳的回答
Ameer Hamza
2020-5-20
There is no special reason other than it was chosen by Mathworks. In MATLAB, text can be loaded in two ways: char array (single quotes) and string (double quotes). They are distinct data types. Strings were introduced much later, so for a long time, char was the only datatype for text. Now, strings are also being supported for almost all the functions that a char array can do. You can get both behaviors from the import tool and the readable.
In import tool, click the "Text option" in the toolbar, and it will give to option to import in either format. String is the default option, therefore, you get double-quotes.
In readtable() you can also use 'TextType' option to get data in either format.
un = readtable("UnitedNations.xlsx", 'TextType', 'string')
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!