How to replace ismissing values in tables

I'm reading a text file into a table and Matlab is returning some values in the table as [1×1 missing].
I would like to replace these by empty cell array {''} but nothing seems to work.
Example below is for a single column in the table. But would prefer to apply to the entire table.
Help please this is causing a lot of grief.
K>> fillmissing(a.data_source_description,'constant',{''})
Error using fillmissing/parseInputs (line 373)
First argument must be numeric, logical, datetime, duration, calendarDuration, string, categorical, char, cellstr, table, or timetable.
Error in fillmissing (line 127)
[A,AisTable,intM,intConstOrWinSize,extM,x,dim,dataVars,ma] = parseInputs(A,fillMethod,varargin{:});

4 Kommentare

suggest you try something like this:
A = readtable(yourfile)
A = table2array(A)
newA = (cellfun(@(x) any(ismissing(x)), A)) = {''};
Azura Hashim
Azura Hashim am 10 Apr. 2020
Hi, it didn't work:
Error: Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
Please show us
class(a.data_source_description)
class(a.data_source_description{1,:})
Peter Perkins
Peter Perkins am 14 Apr. 2020
If the thing you have really displays some elements as [1×1 missing], then you probably have a string array or a cell array. A string array should not cause fillmissing to fail, so I'm guessing cell array. But apparently not a cell array of only char vectors (a "cellstr"), or fillmissing would also not error.
Attach the file, or a portion of it, and show the types of what you've read in, per Walter's question.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Produkte

Gefragt:

am 9 Apr. 2020

Kommentiert:

am 14 Apr. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by