data import from excel (csv)

14 ビュー (過去 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 Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by