dlmread with ^ as delimiter
Mostrar comentarios más antiguos
Hi, Attached a text file where the ^ delimiter works well to import it to excel. The automatic import tab in matlab is failing to import it . I tried also the dlmread function using '^' as a delimiter but it didn't work. Any help is appreciated
4 comentarios
Azzi Abdelmalek
el 28 de Jun. de 2015
No file attached
Jan
el 28 de Jun. de 2015
Please post the used code. We cannot guess, if it contains a typo. And explain "didn't work" with details: Do you get an error message or do the results differ from your expectations?
wesso Dadoyan
el 28 de Jun. de 2015
wesso Dadoyan
el 28 de Jun. de 2015
Editada: dpb
el 28 de Jun. de 2015
Respuestas (2)
"Trouble reading number from file (row 1u, field 1u) ==>rssd9999^rssd9001^BHCK0081^BHCK0395^..."
>> help dlmread
dlmread Read ASCII delimited file.
RESULT = dlmread(FILENAME) reads numeric data from the ASCII
delimited file FILENAME. The delimiter is inferred from the formatting
of the file.
...
All data in the input file must be numeric. dlmread does not operate
on files containing nonnumeric data, even if the specified rows and
columns for the read contain numeric data only.
You can't read the file with dlmread per the doc above; it must be numeric data only. Use textscan
ADDENDUM
OK, w/ more info on the file that that's a header line, if you have recent release of Matlab, try readtable instead. It should figure out the number of elements/record automagically.
3 comentarios
wesso Dadoyan
el 28 de Jun. de 2015
Walter Roberson
el 28 de Jun. de 2015
The column headers are stored in the file, right? dlmread() cannot handle text anywhere in the file.
dpb
el 28 de Jun. de 2015
That IS nonumeric data in the file; reread the help...
Jan
el 28 de Jun. de 2015
DataStr = fileread('bhcf0003.txt');
DataCell = regexp(DataStr, '\^', 'split');
Now you have a cell string: {'rssd9999', 'rssd9001', 'BHCK0081', ...}
1 comentario
wesso Dadoyan
el 28 de Jun. de 2015
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!