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 <<
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!