Save in App designer text area value not as .txt, .dat, or .csv file - Matlab
5 次查看(过去 30 天)
显示 更早的评论
I have tried to save an App designer text area value not as .txt, .dat, or .csv file (used for delimited text files) but rather as an .xyz format (mainly it is just a text file with different extension name).
I used this code line:
writecell(app.XYZfilecontentTextArea.Value, 'E:\SCH.xyz', 'QuoteStrings',false);
and I get this Error using writecell Unrecognized file extension '.xyz'. Use the 'FileType' parameter to specify the file type.
Any idea how can I save my data? It works fine if I wish to save it as txt.
0 个评论
回答(2 个)
Voss
2023-10-16
writecell(app.XYZfilecontentTextArea.Value, 'E:\SCH.xyz', 'QuoteStrings',false, 'FileType','text');
0 个评论
dpb
2023-10-16
编辑:dpb
2023-10-17
writecell(app.XYZfilecontentTextArea.Value, 'E:\SCH.xyz', 'QuoteStrings',false,'FileType','text');
Although from just a practical standpoint, if it is a text file, then .txt would seem a much more logical extension to pick unless there really is some other meaning that is assigned to xyz that has bearing on the file content/application.
It doesn't really matter what a file is named other than one of some convenience with some of the OS conventions like file association with applications and the need for special handling like the above when go against convention in MATLAB, other than there are some applications like Excel that simply won't allow such shenanigans. I've not checked recently whether it would let you import such a file or not; I know it won't open a .xls_ file of any variety unless the extension matches what is expected for the format; that's how it chooses the engine with which to try to open it.
ADDENDUM
" I've not checked recently whether it would let you import such a file or not;..."
I just did; it will let you open a csv file not named as such, but you then have to go thru the import wizard by hand to set the delimiter to match in order for Excel to import the fields into cells--by default it picks tab, not comma and you get every record in a single cell. All in all, it just seems like abadidea™ to not use conventional naming unless there's a very specific reason otherwise; looks a though will likely just cause trouble down the line.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!