LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] joining columns/removing commas in a CSV file?

[ILUG] joining columns/removing commas in a CSV file?

Stephen_Reilly at dell.com Stephen_Reilly at dell.com
Wed Nov 15 14:39:31 GMT 2000


sed "s/\(.*\),\(.*\),\(.*\),\(.*\),\(.*\),\(.*\)/\1\2\3\4,\5,\6/g" file
my mind hurts ... but this will do it :)


-----Original Message-----
From: kevin lyda [mailto:kevin at suberic.net]
Sent: Wednesday, November 15, 2000 1:24 PM
To: irish linux users group
Subject: Re: [ILUG] joining columns/removing commas in a CSV file?


On Wed, Nov 15, 2000 at 11:32:34AM -0000, Gary McCloskey wrote:
> big CSV file, need to merge particular columns. 
> => removing particular commas, e.g. to join the 4th,5th, 6th and 7th
columns, remove the 4th, 5th, 6th commas
> 1,2,3,4,5,6,7,8,9 => 1,2,3,4567,8,9
> 
> thought that tr, cut or paste might help : just gave me a headache

does this make the headache go away:

perl -pe '/((?:.*?,){3})(.*?),(.*?),(.*?),(.*)/;$_="$1$2$3$4$5\n"'

i miss my computational theory course.  of course, what i really
wanted was:

perl -pe '/((?:.*?,){3})(?:(.*?),){3}(.*)/;$_="$1$2$3$4$5\n"'

but the references don't work like that.  perhaps i'm missing something.

kevin

ps  no, in the past week of beating my head against modems, not a bit of
    modem spew has actually been a valid perl program...

-- 
kevin at suberic.net        q: what's the difference between batman & b. gates?
fork()'ed on 37058400    a: when batman fought the penguin, he won.
meatspace place: home                             http://suberic.net/~kevin/
 >> want privacy? www.gnupg.org or www.pgp.com.  encrypted mail preferred <<

-- 
Irish Linux Users' Group: ilug at linux.ie
http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
List maintainer: listmaster at linux.ie




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell