Add header to my new extracted data from a table?
Show older comments
Hello, I have a .csv file that contain odd characters (french accent characters). I read the file with readtable command. Now from the table i extracted only 4 columns and their values having dimension x1data[(1354x4 double)]. I now need to add header to this new table and save it. I form a cell array col [%dimenion(1x4 cell)]. It don´t happen to add it using ´join´,´vertcat´ or ´horzcat´. I tried to convert both the data and col into table but it still gives me error. Can anyone help me how can i add header to a new data extracted from the original file? here is my line of code:
data= readtable('my_file.csv');
x1data= [data{:,3}(:,1), data{:,4}(:,1), data{:,6}(:,1), data{:,9}(:,1)]; %select only the data of interest
col_header={'time in seconds','point duration','epoch size','stage'}; %header for the x1data
col=cell2table(col_header); % (1x4 table)
mydata=array2table(x1data); % (1354x4 table)
Tnew=[mydata;col];
save the new table in new data
%csvwrite('16033NP3_ExtraitEvts.csv',col_header); %Write data and headers
Thank you
1 Comment
mahrukh jamil
on 15 Jul 2016
Edited: Walter Roberson
on 15 Jul 2016
Accepted Answer
More Answers (0)
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!