How to import dates from excel files

1 次查看(过去 30 天)
Upon running the following code:
filename = 'Bitcoin_Data_Lab_9.xlsx';
A = xlsread(filename);
T = readtable(filename)
The outputs are similar to the spreashseet but not identical. A has completely deleted the dates column and only shows the numerical ones, while T has every column but every date which was in the dates column is now NaN (my dates are formatted as (mm/dd/yyyy). How can I make it so that the dates are displayed (preferably with xlsread but either function is acceptable).
For reference, the excel file is attached above.
  2 个评论
Mitchell Thurston
Mitchell Thurston 2021-12-8
my guess is you're going to want to interpret the dates column as a string. going off of this, it would be something like
opts = detectImportOptions(filename);
opts = setvartype(opts, 'Dates','string');
T = readtable(filename, opts)
Matthew Urena
Matthew Urena 2021-12-8
Definitely looked hopeful, but this is what the first rows of my table were output as:

请先登录,再进行评论。

回答(1 个)

Yusuf Suer Erdem
Yusuf Suer Erdem 2021-12-8
Could you try like below?
filename = 'Bitcoin_Data_Lab_9.xlsx';
A = readcell(filename);
T = readtable(A)
  1 个评论
Matthew Urena
Matthew Urena 2021-12-8
After running this, I am met with the following error messages:
Error using readtable (line 198)
File input must be a non-empty character vector or string scalar.
Error in Untitled (line 4)
T = readtable(A)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by