Re: How to remove trailing commas and points from a CSV file ?
- From: peng.kyo@xxxxxxxxx (Jeff Peng)
- Date: Fri, 27 Jun 2008 00:35:56 +0800
On Fri, Jun 27, 2008 at 12:26 AM, Erasmo Perez <perez.erasmo@xxxxxxxxx> wrote:
a,b,.,.,.,.,.,.,.
b,c,d,.,.,.,.,.,.
e,f,g,h,.,.,.,.,.
i,j,k,l,m,.,.,.,.
and so on
My problem: how could I get rid of the trailing points and commas, so
the output CSV file could get following neat format (without the
trailing points and its commas separators):
a,b
b,c,d
e,f,g,h
i,j,k,l,m
Hello,
Follow your sample data, you may try:
use strict;
while(<DATA>) {
s/(\,\.)+$//;
print;
}
__DATA__
a,b,.,.,.,.,.,.,.
b,c,d,.,.,.,.,.,.
e,f,g,h,.,.,.,.,.
i,j,k,l,m,.,.,.,.
The output is:
a,b
b,c,d
e,f,g,h
i,j,k,l,m
--
Jeff Peng - Peng.Kyo@xxxxxxxxx
http://home.arcor.de/mailerstar/jeff
.
- Follow-Ups:
- Re: How to remove trailing commas and points from a CSV file ?
- From: Perez Erasmo
- Re: How to remove trailing commas and points from a CSV file ?
- References:
- How to remove trailing commas and points from a CSV file ?
- From: Erasmo Perez
- How to remove trailing commas and points from a CSV file ?
- Prev by Date: No Dialog Boxes working
- Next by Date: Re: how to implement this with perl
- Previous by thread: How to remove trailing commas and points from a CSV file ?
- Next by thread: Re: How to remove trailing commas and points from a CSV file ?
- Index(es):
Relevant Pages
|