필터 지우기
필터 지우기

readtable reading string columns as matrix when lots of empty rows.

조회 수: 13 (최근 30일)
Ryan Rose
Ryan Rose 2021년 6월 29일
댓글: Ryan Rose 2021년 6월 29일
I work with very large tables (3 million or so rows). I use the readtable function to import them into matlab. recently I noticed a bug, when I have a large amount of empty cells in a column that is supposed to be a column of strings. readtable reads the column as a matrix and all the cells are NaN. Is there a way to set specific columns to be read as cells or chars to prevent this problem. I would prefer to not format all the columns as matlab is pretty good at this already and they can move around and change.
The code works fine with smaller data or if the strings show up earlier in the data.
Any help would be appriciated.

채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 6월 29일
편집: Scott MacKenzie 2021년 6월 29일
You ask: Is there a way to set specific columns to be read as cells? Yes, you can do this:
opts = detectImportOptions('filenname.xlsx');
opts = setvartype(opts, {'name_of_column'}, 'cell');
T = readtable('filename.xlsx', opts);
See the readtable documentation for a detailed example.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by