- C = textscan(fileID,formatSpec,N) reads file data using the formatSpec N times, where N is a positive integer. To read additional data from the file after N cycles, call textscan again using the original fileID. If you resume a text scan of a file by calling textscan with the same file identifier (fileID), then textscan automatically resumes reading at the point where it terminated the last read.
How to ignore or delete the last row of a text file when importing?
7 次查看(过去 30 天)
显示 更早的评论
I am reading in data using textscan. Often times the last row of data is bad and throws an error. How can I ignore the last line? or is there code to delete the last row of data in the text file programmatically?
0 个评论
采纳的回答
Star Strider
2015-5-31
It’s difficult to be specific without your file. If you know how many lines you want to read, you can set that limit as a parameter.
From the documentation:
2 个评论
更多回答(1 个)
Image Analyst
2015-5-31
Put it in a try catch block. Look it up in the help. You can just have your catch block be empty if you want to ignore any errors.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Data Preparation 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!