separate data from file

2 vues (au cours des 30 derniers jours)
Jay Hanuman
Jay Hanuman le 23 Nov 2016
Modifié(e) : KSSV le 23 Nov 2016
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.
  2 commentaires
KSSV
KSSV le 23 Nov 2016
No file attached..
Jay Hanuman
Jay Hanuman le 23 Nov 2016
I forgot, now I attached

Connectez-vous pour commenter.

Réponse acceptée

KSSV
KSSV le 23 Nov 2016
Modifié(e) : KSSV le 23 Nov 2016
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) ;

Plus de réponses (1)

Walter Roberson
Walter Roberson le 23 Nov 2016
regexp() probably
  1 commentaire
Walter Roberson
Walter Roberson le 23 Nov 2016
Or possibly strsplit

Connectez-vous pour commenter.

Catégories

En savoir plus sur Large Files and Big Data dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by