Datastore can't convert variable to type double
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Steven Lord
2018-6-8
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.)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!