| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
Actually from the data shown it is column number 6 rather than 7 that is being processed. Hence, we do as follows:
sed -e '
s/;/\n/6; # mark the 6th field at its right end
s/^/;/; # add a dummy field
s/;/\n/6; # mark the 6th field at its left end
s/.//; # remove the dummy field
;# split the 6th field into their numeric & alphabetic counterparts
;# and then separate them by the separator semicolon
s/\(\n[ ]*[0-9]*\)[ ]*\([a-zA-Z]*\n\)/\1;\2/
;# finally, reverse the markers
y/\n/;/
' yourcsvfile
---In [email protected], <rachid.mokrani@...> wrote :
Hi,
Do you have a simple proposal with sed / awk.
In this exemple, need to split column 7
Company A ; NAME A ; FIRSTNAME 1 ; JOB 1 ; Town 1 ; 145854 abVFrd ; COMMENT 1 ;
And obtain 8 columns (7 always a number - 8 always alphabetic)
Company A ; NAME A ; FIRSTNAME 1 ; JOB 1 ; Town 1 ; 145854 ; abVFrd ; COMMENT 1 ;
But sometime the colum 7 can have
; 145854 abVFrd ;
Need to have
; 145854 ; abVFrd;
; 145854;
Need to have
; 145854; ;
; abVFrd;
Need to have
; ; abVFrd;
; ;
Need to have
; ; ;
[Non-text portions of this message have been removed]