How to readtable filtering columns and rows?
Show older comments
Hello,
Maybe someone knows if there is a way to readtable not only defining the column names but defining rows values as well? I have a *.csv file :
ReceivingDate ReceivingTime SecurityID Asset EntryType EntryPrice EntrySize
20180429 16:53:28.944250499 10062 FOB A 0 0
20180429 16:53:28.944250499 10062 FOB B 0.03125 5
20180429 16:53:33.913990105 10062 FOB A 0 0
20180429 16:53:33.913990105 10062 FOB B 0 0
20180429 16:53:41.173484956 10062 FOB A 0.03125 5
20180429 16:53:41.173484956 10062 FOB B 0 0
20180430 16:54:55.254652081 10062 FOB A 0.03125 5
20180430 16:54:55.254652081 10062 FOB B 0.078125 1
20180430 17:06:59.219609240 10062 FOB A 0.03125 5
20180430 17:06:59.219609240 10062 FOB B 0 1
20180430 17:11:55.316770824 10062 FOB A 0.03125 5
20180430 17:11:55.316770824 10062 FOB B 0.0078125 1
I use this code to define which columns to read:
opts = detectImportOptions('trys.csv');
opts.SelectedVariableNames = {'ReceivingDate','ReceivingTime','EntryType','EntryPrice'};
t = readtable('trys.csv',opts);
And the result is as follows:
ReceivingDate ReceivingTime EntryType EntryPrice
20180429 16:53:28.944250499 A 0
20180429 16:53:28.944250499 B 0.03125
20180429 16:53:33.913990105 A 0
20180429 16:53:33.913990105 B 0
20180429 16:53:41.173484956 A 0.03125
20180429 16:53:41.173484956 B 0
20180430 16:54:55.254652081 A 0.03125
20180430 16:54:55.254652081 B 0.078125
20180430 17:06:59.219609240 A 0.03125
20180430 17:06:59.219609240 B 0
20180430 17:11:55.316770824 A 0.03125
20180430 17:11:55.316770824 B 0.0078125
Would it be possible to filter row values (20180430), that final readtable result would be
ReceivingDate ReceivingTime EntryType EntryPrice
20180430 16:54:55.254652081 A 0.03125
20180430 16:54:55.254652081 B 0.078125
20180430 17:06:59.219609240 A 0.03125
20180430 17:06:59.219609240 B 0
20180430 17:11:55.316770824 A 0.03125
20180430 17:11:55.316770824 B 0.0078125
Accepted Answer
More Answers (0)
Categories
Find more on Standard File Formats in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!