Search Results

Search: Posts Made By: awayand
6,654
Posted By alister
Another perl approach: perl -F, -ane...
Another perl approach:
perl -F, -ane 'map({$F[2]=$_; print join(",",@F)} split(/-/,$F[2],-1))' file

Regards,
Alister
6,654
Posted By Klashxx
That's a nice one.. let me post a version based...
That's a nice one.. let me post a version based on yours using regex..
perl -ane '/^([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)$/;
foreach (split(/-/,$3)){print "$1,$2,$_,$4,$5";}' abc.dat
6,654
Posted By danmero
awk -F,...
awk -F, '{n=split($3,a,"-");for(i=0;++i<=n;){$3=a[i];print}}' OFS="," file
6,654
Posted By pravin27
Hi , Try this... perl formatCSV.pl inputfile...
Hi , Try this...

perl formatCSV.pl inputfile



#!/usr/bin/perl

while (<>) {
chomp;
if (/(.+?)\,(\w+\-.+?)\,(.*)/){
$str=$2;
chomp $str;
@array = split /-/,$str;
...
6,654
Posted By pseudocoder
$ cat abc.dat a,b,C-D-E,f,g h,i,J,k,l ...
$ cat abc.dat
a,b,C-D-E,f,g
h,i,J,k,l
m,n,O-P-Q-R-S,t,u
v,w,X-Y,z,a
$ perl -ane '@x=split(/,/,$_); @y=split(/-/,$x[2]);
foreach $char (@y) { print "$x[0],$x[1],$char,$x[3],$x[4]"; }' abc.dat...
1,843
Posted By vgersh99
nawk ' BEGIN { FS=OFS="," ...
nawk '
BEGIN {
FS=OFS=","
SEP="-"
stub="<stub>"
}
{
idx=$1 OFS $2 OFS stub OFS $4 OFS $5
a[idx]=(idx in a)?a[idx] SEP $3:$3
}
END {
for(i in a)...
Showing results 1 to 6 of 6

 
All times are GMT -4. The time now is 05:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy