data import from excel (csv)

조회 수: 24 (최근 30일)
hafiz hashim
hafiz hashim 2019년 10월 25일
댓글: Star Strider 2019년 10월 25일
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
Guillaume
Guillaume 2019년 10월 25일
Attach an example csv file.
hafiz hashim
hafiz hashim 2019년 10월 25일
HI i have attached the file.
Thanks

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2019년 10월 25일
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
hafiz hashim
hafiz hashim 2019년 10월 25일
Thanks for your help
Star Strider
Star Strider 2019년 10월 25일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by