Borrar filtros
Borrar filtros

Datastore can't convert variable to type double

3 visualizaciones (últimos 30 días)
Birtan Derin
Birtan Derin el 8 de Jun. de 2018
Comentada: Birtan Derin el 8 de Jun. de 2018
I have a collection of excel sheets in a folder which all have the same formatting etc. I called spreadsheetDatastore on it, then created a tall array. However, it seems like there is a problem with the read functionality.
ds = spreadsheetDatastore('J:\Fixed _Inc\Internal\birtanderin\MS Data\25-35\*.xlsx');
tt = tall(ds);
s = size(tt.Coupon);
I get the following error:
Error using tall/gather (line 50)
Internal problem while evaluating tall expression. The problem was:
Unable to convert variable 'Coupon' in sheet 'Sheet4' in file 'J:\Fixed _Inc\Internal\birtanderin\MS Data\25-35\2007.xlsx' to type
'double'.
Learn more about errors encountered during GATHER.
Error in database_build (line 20)
size = gather(s);
Caused by:
Unable to convert variable 'Coupon' in sheet 'Sheet4' in file 'J:\Fixed _Inc\Internal\birtanderin\MS Data\25-35\2007.xlsx' to
type 'double'.
When I checked ds to see the variable type of 'Coupon', it says double, so I don't understand why Matlab gives me error trying to convert a type double variable to type double.
The weirdest thing is, if I try the same code on small dataset (52 rows), it works perfectly. This only seems to be a problem with a large dataset. Please help.

Respuestas (1)

Steven Lord
Steven Lord el 8 de Jun. de 2018
Look at sheet Sheet4 in the file 'J:\Fixed _Inc\Internal\birtanderin\MS Data\25-35\2007.xlsx'. Does it have something that can't be converted into a number in the Coupon column? Maybe whatever wrote that sheet accidentally put text in that column instead of a number (perhaps by omitting one of the previous columns, thereby putting whatever should have been in the next column into Coupon instead.)
  1 comentario
Birtan Derin
Birtan Derin el 8 de Jun. de 2018
Thank you for your answer. I already made sure every entry on Coupon column consists of numerical values. In fact I brought that specific column using xlsread without any issues, and the variable type was a double. This only seems to be a problem when I try to bring that column with datastore, and operate on tall arrays.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by