Re: How to remove trailing commas and points from a CSV file ?
- From: perez.erasmo@xxxxxxxxx (Perez Erasmo)
- Date: Thu, 26 Jun 2008 12:14:09 -0500
Hi dear Jeff:
Thank you very much for your help
Yiur script is working flawlessly
Just another question:
How could I re-write your script in order to treat the __DATA__
portion of your code as an external file ?
I happen to have the whole CSV file and I would not want to mix
directly with it, but to reference it from the perl code
How could I accomplish that ?
Should I substitue the <DATA> for the name of the CSV file in the perl code ?
Thank you very much for any help
Regards
Erasmo
On 26/06/2008, Jeff Peng <peng.kyo@xxxxxxxxx> wrote:
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:
- References:
- How to remove trailing commas and points from a CSV file ?
- From: Erasmo Perez
- Re: How to remove trailing commas and points from a CSV file ?
- From: Jeff Peng
- How to remove trailing commas and points from a CSV file ?
- Prev by Date: Re: parsing a tree like structure
- Next by Date: Re: How to remove trailing commas and points from a CSV file ?
- Previous by thread: Re: 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
|