Textscan with '@' as delimiter
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
AMM
el 7 de Mayo de 2020
Respondida: per isakson
el 13 de Mayo de 2020
I'm working with an inherited script that calls TEXTSCAN as follows:
allData = textscan(fid,'%s','Delimiter','@');
What does the at-sign delimiter parameter do, and is this documented anywhere?
I don't see anything in the TEXTSCAN help for this, but when I parse the same text file with and without that parameter specified, I get different results. The input file contains no explicit at-sign characters anywhere. Is TEXTSCAN treating the @ as some special control character?
5 comentarios
Walter Roberson
el 9 de Mayo de 2020
Please attach your data file, and also the code you use to reproduce the problem.
The tests I have done find nothing special about using @ . The effect I get when I use any character not found in the file exactly the same as if I use
textscan(fid, '%s', 'Delimiter', '\n', 'Multiple', true)
or
textscan(fid, '%s', 'whitespace', '\n')
and the effect is:
- each time the %s fires, skip all leading spaces and newlines
- once the %s starts reading something non-blank, continue until the first newline
Respuesta aceptada
per isakson
el 13 de Mayo de 2020
I've reproduced your result on R2018b. The result is according to the textscan documentation - I think.
- out1 is a cell array of character arrays with one item per cell
- out2 is a cell array of character arrays with one data row per cell
Case 1. One or more spaces are used as delimiter. That's by default and regardless of the value of 'MultipleDelimsAsOne'. Doc says: If you do not specify a delimiter, then: the delimiter characters are the same as the white-space characters.
Case 2. '@' is used as delimiter. '%s' matches the entire row, since no delimiter is found. (I don't find a sentence in the documentation to copy. There is something about row-oriented that goes without saying.)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Text Data Preparation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!