I've a text file containing the following sample data:
#*##*****# SOME TEXT#-----AAAAA1D2R2D2C3POF9I4TEST#*****# LOCATION#*****
I'm extracting the character strings using the following code;
fid = fopen('Textscan_Sample_Data.txt');Data = textscan(fid, '%s', 'HeaderLines', 5, 'CommentStyle', {'#*****', '#*****'});fclose(fid);
The result is a 6 x 1 cell matrix containing the following;
'AAAA''A1D2''R2D2''C3PO''F9I4''TEST'
This works well when the number of header lines is a known, fixed value. But when the number of lines varies, the approach is no longer valid.
It doesn't appear TEXTSCAN can account for multiple comment styles. Is there a way to account for a varying number of header lines while still using the TEXTSCAN function to account for the comment style at the end of the file?
Best Answer