Readtable produces a 1x 1 table full of strange characters
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am loading tables from several large nonuniform .txt files delaminated with spaces. I'm using readtable and most of the tables get loaded without an issue but some files generate a 1x1 table full of stange characters. The code I'm using to load:
filename = 'filename.txt'
opts = detectImportOptions(filename);
opts = setvartype(opts,'char'); % or 'string'
Table = readtable(filename,opts);
I can't tell what is causing some files to be read like this.
1 Kommentar
Les Beckham
am 17 Okt. 2023
If you provide a sample file that causes this issue you will be more likely to get a good answer. Use the paper clip icon in the INSERT section of the comment editor toolbar to attach it.
Antworten (1)
Sulaymon Eshkabilov
am 17 Okt. 2023
If some of the imported data looks strange, that means the setvartype option is not appropriate for the data to be imported. See these two examples:
filename = 'DATA_2_MIX.txt';
opts = detectImportOptions(filename);
opts = setvartype(opts,'double'); % 'single','char' or 'string'
Table = readtable(filename,opts)
filename = 'DATA_2_MIX.txt';
opts = detectImportOptions(filename);
opts = setvartype(opts,'char'); % 'single','char' or 'string'
Table = readtable(filename,opts)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!