Ignore format errors using textscan
Show older comments
I been using textscan to read large text files containing data. Here's some lines to get an idea of what it looks like:
2015,1,1,23,1,23,100,9034
2015,1,1,23,1,23,203,8940
2015,1,1,23,1,23,313,8807
There's several million lines in the .txt file and every now and then there's a small error. Some strange symbols in the line or missing data (early end) of a line and very inconsistent. Whenever textscan comes across one of these lines it gives me the following error;
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
I would like it to ignore these lines and continue reading all data. Anybody can give me advice on what I can do best?
Thanks!
1 Comment
Stephen23
on 12 Jan 2015
The error message that you posted does not refer to textscan, but rather to horzcat...
Accepted Answer
More Answers (1)
1 Comment
Star Strider
on 12 Jan 2015
My pleasure!
Yours is a new approach — at least not one I’ve seen before — so +1 for your Answer and +1 your Question.
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!