create a time table from specific time date format

1 回表示 (過去 30 日間)
Sonima
Sonima 2018 年 8 月 15 日
編集済み: Sonima 2019 年 8 月 15 日
Hello!
I have a historical data that I need to import and create a timetable from. the date and time are not in the standard format that I import and convert. I would appreciate if you can help me how can I do so (data attached)
Date,Time,Open,High,Low,Close,Volume
20010102,230000,64.30,64.31,64.27,64.28,48
20010102,231500,64.28,64.29,64.27,64.28,52
20010102,233000,64.28,64.28,64.25,64.26,40
20010102,234500,64.27,64.35,64.27,64.35,44
20010103,000000,64.30,64.44,64.30,64.44,52
Thanks.

採用された回答

jonas
jonas 2018 年 8 月 15 日
編集済み: jonas 2018 年 8 月 15 日
The format is not an issue but there are several ways to import. Here is one:
opts = detectImportOptions('data.txt');
opts = setvartype(opts, 'char');
tbl = readtable('data.txt',opts);
C=strcat(tbl.Date, {' '}, tbl.Time)
datetime(C,'inputformat','yyyyMMdd HHmmSS')
You can also experiment a bit more with the detectImportOptions to avoid post-processing
opts = detectImportOptions('data.txt');
opts = setvartype(opts,'Date','datetime');
opts = setvartype(opts,'Time','datetime');
opts = setvaropts(opts,'Date','InputFormat','yyyyMMdd')
opts = setvaropts(opts,'Time','InputFormat','HHmmss')
T = readtable('data.txt',opts)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by