Why does 'readtable' generate NaN values for text data imported from a file in R2020a or later?
Show older comments
I'm reading in an Excel spreadsheet file that has columns containing numerical and text data.
Depending on the order of the values, 'readtable' appears to choose different data types.
The data in the spreadsheet is:
COL_1 | COL_2
TEXT_1 | 2
TEXT_2 | TEXT
-1 | 2
'readtable' returns the following data:
>> readtable('MixedInputs.xlsx')
ans =
3×2 table
COL_1 COL_2
________ _____
{'TEXT_1'} 2
{'TEXT_2'} NaN
{'-1' } 2
COL_1 imports all data as character vectors.
COL_2 has broken data 'NaN' where "TEXT" should be read.
Is this expected behavior? I was expecting 'readtable' to revert all data to character vectors or strings, for any column containing mixed data types.
Accepted Answer
More Answers (0)
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!