Working with dates, problem with 10th month import from exl file
Afficher commentaires plus anciens
I have a problem when loading in a data set where january columns are expressed as yyyy.01, but october is expressed as yyyy.1.
Since the 0 after 1 in october disapperas, matlab gives me aug, sept, jan, nov, when creating a datetime column.
opts = spreadsheetImportOptions("NumVariables", 4);
opts.Sheet = "Data";
opts.DataRange = "A9:D1811";
opts.VariableNames = ["Date", "Var2", "D", "E"];
opts.SelectedVariableNames = ["Date", "D", "E"];
opts.VariableTypes = ["char", "char", "double", "double"];
opts = setvaropts(opts, "Var2", "WhitespaceRule", "preserve");
opts = setvaropts(opts, "Var2", "EmptyFieldRule", "auto");
iedata = readtable("ie_data.xls", opts, "UseExcel", false);
iedata.Date = datetime(iedata.Date,'InputFormat','yyyy.MM');
clear opts
So the output is
head(iedata,12)
ans =
12×3 table
Date D E
___________ ____ ___
01-Jan-1871 0.26 0.4
01-Feb-1871 0.26 0.4
01-Mar-1871 0.26 0.4
01-Apr-1871 0.26 0.4
01-May-1871 0.26 0.4
01-Jun-1871 0.26 0.4
01-Jul-1871 0.26 0.4
01-Aug-1871 0.26 0.4
01-Sep-1871 0.26 0.4
01-Jan-1871 0.26 0.4
01-Nov-1871 0.26 0.4
01-Dec-1871 0.26 0.4
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Dates and Time dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!