一、
说明:Excel中数据含有 日期,double如何实现多个表合并
解:
path = 'E:\xxx\';
namelist = dir([path,'*.csv']);
L = length(namelist);
a = [];
for i = 1:L
filename{i} = [path,namelist(i).name];
bb = readtable(filename{i},'Range','A1:G2881');%读取excel文件,选定区域'B2:T2881'
a= [a;bb];
namelist(i).name;
end
%%%writetable(a, '汇总前6tags.csv'); %table (2880*#{day})*#{tags},存为新
tt=toc
%[数据格式处理]数据含有日期与数值格式,转换为皆数值
tmp=table2array(a(:,'Var1')); %table中取某列 或a(:,1)
cc1=datenum(tmp); %double
cc2=table2array(a(:,{'Var2','Var3','Var4'}));%double %table中取几列 或a(:,2:4)
二、
问题:Excel中数据含有 日期,double, 字符串如(‘null’),如何实现多个表合并
解:
clc;clear
path = 'E:\xxx\';
namelist = dir([path,'*.csv']);
L = length(namelist);
a = [];
for i = 2:L
filename{i} = [path,namelist(i).name];
bb= readcell(filename{i},'Range','A2:G2881');%读取excel文件,选定区域'B2:G2881'
a= [a;bb];
namelist(i).name;
end
data1=cell2table(a);%由元胞数组转化为矩阵 (2880*#{day})*#{tags}
tmp=table2array(data1(:,'a1')); %table中取某列 或a(:,1)
cc1=datenum(tmp); %double
cc2=table2array(data1(:,{'a2','a3','a4'}));%double %table中取几列 或a(:,2:4)
结果:
data1为 table类型