MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   Matlab Quickie:测试文本文件是否为空 (https://www.labfans.com/bbs/showthread.php?t=23157)

poster 2019-12-10 20:30

Matlab Quickie:测试文本文件是否为空
 
一个简单的问题:我正在matlab 7.x中打开一个文件,我想在读取文件之前先测试它是否为空。最好的方法是什么?



[B]回答:[/B]

从[URL="https://stackoverflow.com/questions/849739/how-do-you-get-the-size-of-a-file-in-matlab"]上一个问题中获得[/URL]一些知识,我将执行以下操作

s = dir('c:\somefile.txt'); if s.bytes == 0 % empty file else % open the file and read it end; 我以空表示,您的意思是文件中实际上没有任何内容,包括换行符。如果用空表示仅换行符,则应继续解决。



[url=https://stackoverflow.com/questions/2338392]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 07:01

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.