data import from excel (csv)

Hi i import data from csv by using readtable command
T = readtable('Report.csv','HeaderLines',8);
the data comes in this form matlab.JPG
how can i seperate datetime in one column and reading in other seperate columns. i would be so grateful if someone could help me out in this
Thanks

2 Comments

Attach an example csv file.
HI i have attached the file.
Thanks

Sign in to comment.

 Accepted Answer

This is perhaps a bit more complicated than it might be, however readtable does not import it properly, so other approaches are necessary:
[D,S] = xlsread('example.csv');
dtts = table(datetime(S(2:end,1), 'InputFormat', 'dd-MM-yy hh:mm:ss a ''GMT''', 'TimeZone', 'UTC'),'VariableNames',S(1,1));
dt = array2table(D, 'VariableNames',S(1,2:end));
T1 = [dtts,dt];
T1_Sample = T1(1:5,:) % Delete Later
producing:
T1_Sample =
5×8 table
timestamp MWS_TOTAL NEB_RWP1_Ladies_Flow_Meter NEB_CWS_METER NEB2_CWS_GENTS_FLOW NEB_CWS_LADIES_FLOW NEB_HWS_LADIES_FLOW NEB_MWS_1ST CANTEEN
____________________ _________ __________________________ _____________ ___________________ ___________________ ___________________ ___________________
20-Nov-2018 10:00:00 15063 1.0076e+06 12350 27269 6.58 36.56 4.8806e+05
20-Nov-2018 12:00:00 15067 1.0079e+06 12354 27274 6.58 36.56 4.881e+05
20-Nov-2018 12:15:00 15068 1.008e+06 12355 27277 6.58 36.56 4.8813e+05
20-Nov-2018 12:30:00 15069 1.008e+06 12356 27277 6.58 36.56 4.8813e+05
20-Nov-2018 12:45:00 15070 1.0081e+06 12356 27279 6.58 36.56 4.8814e+05
Experiment to get the result you want.

2 Comments

Thanks for your help
As always, my pleasure!

Sign in to comment.

More Answers (0)

Products

Release

R2018a

Community Treasure Hunt

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

Start Hunting!