separate data from file

2 次查看(过去 30 天)
Jay Hanuman
Jay Hanuman 2016-11-23
编辑: KSSV 2016-11-23
I attached data file. data is in format of
source _ip:source_port->destination_ip:destination_port
I want to take out only source_ip data from that, how to do.

采纳的回答

KSSV
KSSV 2016-11-23
编辑:KSSV 2016-11-23
load('n0 1.mat') ;
s = VarName6 ;
idx = strfind(s, ':');
idx = cell2mat(idx) ;
idx = idx(:,1)-1 ;
iwant = cellfun(@(x,idx) x(1:idx),s,num2cell(idx), 'UniformOutput', false) ;
Or
load('n0 1.mat') ;
s = VarName6 ;
s1 = regexp(s,':','split') ;
iwant = cellfun(@(x) x{1}(:)',s1, 'UniformOutput', false) ;

更多回答(1 个)

Walter Roberson
Walter Roberson 2016-11-23
regexp() probably

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by