How to ignore additional columns when reading a file using textscan?

6 ビュー (過去 30 日間)
yashvin
yashvin 2015 年 6 月 16 日
コメント済み: Walter Roberson 2016 年 5 月 19 日
I want to extract the 3rd column which contains the time data. I have managed to do it using
if true
f = fopen ('trial1.csv');
C = textscan(f,'%n %n %s','Delimiter',',','HeaderLines', 1)
TimeStamp=C{3}(1)'
DateVector = datevec(TimeStamp)
fclose(f);
end
In the future, I can have additional 50(for eg) new columns. I want to know is there way in matlab such that i do not define these additonal columns which can comprise of string, floating numbers etc. My textscan will become so big! Any other way of extracting the time values in column 3?
2. Secondly, why is my timeStamp value not including the seconds? It is only including until the minutes!
Please find attached the trial1.csv file
  2 件のコメント
yashvin
yashvin 2015 年 6 月 16 日
Find attached the trial1.csv file
Walter Roberson
Walter Roberson 2016 年 5 月 19 日
Your csv file does not include any seconds.

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

採用された回答

Ingrid
Ingrid 2015 年 6 月 16 日
just type doc textscan and you can find this there. So you need to add the * after the % sign for data that you do not want to read in
  1 件のコメント
Iain
Iain 2016 年 5 月 18 日
Also using %*[^\n] at the end of the formatting string allows you to skip to the end of the line which I think is what you were asking about "not define these additonal columns"

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by