Wrong date while importing .csv
3 次查看(过去 30 天)
显示 更早的评论
Having a problem when i import daily .csv files. More specifically, when i plot my xy data(x axis contains date and time stamp), in every different daily file, MATLAB shows todays date. Any ideas?
采纳的回答
jonas
2018-8-24
编辑:jonas
2018-8-24
The date is not automatically assigned because it's not in the data but in the name of the file. You could do something like this:
files=dir('folderpath~\*.csv');
for i=1:length({files.name})
date=files(i).name;
date=regexprep(date,'.csv','')
data=readtable(files(i).name);
t{i}=data{:,1}+datetime(date);
xy{i}=data{:,2:3}
end
Now you have two cell arrays, t and xy, where the former has all time data and the latter all other data.
18 个评论
更多回答(0 个)
另请参阅
类别
在 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!