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!