datastore multiple delimiter (space, tab)

6 ビュー (過去 30 日間)
tkd
tkd 2019 年 10 月 21 日
コメント済み: tkd 2019 年 10 月 22 日
Hello,
I have the following data on my 1st column, MM/dd/YYYY HH:mm:ss.SSSSS. How do I seperate the two?
When using
ds=datastore('data.txt');
it'll group MM/dd/YYYY HH:mm:ss.SSSSS into Var1.
Var1
___________________________
'MM/dd/YYYY HH:mm:ss.SSSSS'
I tried
ds=datastore('data.txt',...
'Delimiter',{' ','/t'});
it'll seperate MM/dd/YYYY to Var1 and all colums after that as Var2.
Var1 Var2
___________ ____________________________________
'MM/dd/YYYY' 'HH:mm:ss.SSSSS DATA DATA DATA ...'
  4 件のコメント
Guillaume
Guillaume 2019 年 10 月 21 日
_Can you attach (with the paperclip icon) an example file? This is so we get the actual characters in your file. The text you've pasted does not have tab characters (just 4 spaces instead of tabs). This example is loaded by datastore by default exactly as you want.
tkd
tkd 2019 年 10 月 21 日
attached dataset.

サインインしてコメントする。

採用された回答

Guillaume
Guillaume 2019 年 10 月 22 日
I should have spotted that straightaway, the way to specify control characters is with a backslash \, not a forward slash /.
ds=datastore('data.txt', 'Delimiter',{' ','\t'}); %\t not /t
will load your file fine. You may need to override the datetime format detected by datastore depending on whether your dates are encoded as 'MM/dd/uuuu' or 'dd/MM/uuuu'
  1 件のコメント
tkd
tkd 2019 年 10 月 22 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by