Delimiter at particular column
Show older comments
Hey
I am getting problem to apply delimiter at particular column. My text file consists of delimited data but I want to use delimited tool only on particular column.
- for e.g. 03:30:45 in 1st column and Cellid:dBm in 2nd column. I want to apply delimiter : only at column 2.
Is there any way? Your respected opinions are appreciated.
4 Comments
Jan
on 18 Sep 2013
It is not clear what you are talking about. There are some colons inside "03:30:45" already. How do you create the text file? Why not printing the colon directly?
Jan
on 18 Sep 2013
What does "when I am using delimiter" exactly mean? Please post the code you are talking of. How can a delimiter "applied" during the import?
The example looks strange:
Time; NID01: dBm;
16:56:12; 53172; -89;
When these are two columns, why do the 2nd line looks like 3 values?
Posting the code you use, a clear small example for the input and a definition of the output in valid Matlab syntax would stop the discussion and allow for a fast solution of your problem.
Muhammad
on 19 Sep 2013
Answers (1)
Azzi Abdelmalek
on 18 Sep 2013
Edited: Azzi Abdelmalek
on 18 Sep 2013
Read all your data with delimiter then recreate the first column.
If
A{1}={'03';'03';'03'}
A{2}={'30';'30';'30'}
A{3}={'45';'46';'47'}
Then
first_column=cellfun(@(x,y,z) [x,':',y,':',z],A{1},A{2},A{3},'un',0)
6 Comments
Muhammad
on 18 Sep 2013
Azzi Abdelmalek
on 18 Sep 2013
You can recreate your time array
s='16 56 12 53172 -89'
a=regexp(s,'\s+','split')
time1=[a{1} ':' a{2} ':' a{3}]
Muhammad
on 18 Sep 2013
Azzi Abdelmalek
on 18 Sep 2013
If you have a cell array like:
s={'16 56 12 53172 -89';'17 56 12 53172 -90';'18 56 12 53172 -91'}
a=regexp(s,'\s+','split')
time1=cellfun(@(x) [x{1} ':' x{2} ':' x{3}],a,'un',0)
Muhammad
on 19 Sep 2013
Jan
on 19 Sep 2013
I do not see any attached file.
Categories
Find more on Text Files in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!