How to validate expected numeric tall array column?

1 Ansicht (letzte 30 Tage)
SL
SL am 24 Okt. 2016
Beantwortet: Adam Filion am 23 Apr. 2018
I have 60 column tall array where I cannot declare expected numeric columns numeric. I exported those numeric columns from Google Spreadsheet, but MATLAB think there is something string, but I cannot confirm it. Code
ds.SelectedFormats{strcmp(ds.SelectedVariableNames, 'Age')} = '%d';
Output
Error using tall
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 4, field number 2) ==> -,male,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,,0,,,,,"lorem, ipsun",0,1,1,0,0,0,0,0,0,0,,,,,,,,,\n
Error in test_tall_array (line 26)
tt = tall(ds);
Caused by:
Reading the variable name 'Age' using format '%d' from file: '/home/masi/test.csv' starting at offset 0.
MATLAB: 2016b OS: Debian 8.5
  1 Kommentar
Kirby Fears
Kirby Fears am 24 Okt. 2016
Bearbeitet: Kirby Fears am 24 Okt. 2016
SL,
The error suggests row 4, field 2 of your data contains an invalid data type. Can you manually view row 4 of your data to confirm this? Is it possible that some data is misaligned within the "Age" column?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Adam Filion
Adam Filion am 23 Apr. 2018
It looks like the data provider uses '-' to denote missing data in some places. The datastore's 'TreatAsMissing' property can solve this.
ds = datastore('*','TreatAsMissing','-');

Kategorien

Mehr zu Large Files and Big Data finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by