How to remove trailing commas and points from a CSV file ?



Hi dear list:

Please forgive my lack of Perl credentials, but i am a complete beginner

But, and that is the problem, I do have an urgent issue and that's why
I came to perl in the very first instance

I have a CSV file, which comes in the following format:

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

I mean, the points repressent missing values in the original CSV,
which are separated by commas

Once the points start to appear in the line, the line does not hold
any not-missing value, I mean, after a points starts, there will be
only points (and their commas separators) till the end of the line

If a perl program could detect a point, in a line, the logic of the
solution could be to make a Return to the next line, forgetting the
rest of the previous line.

How could I manage that operation with perl ?

Thank you very much for your help

Regards

Erasmo
.



Relevant Pages

  • Re: Case sensitive arguments to coco text & copy mechanism
    ... >>Perl seems to be so ubiquitous that this may not be the drawback it used ... I am trying fpx3 now and it does seem very ... It can even handle spaces in arguments to macros. ... > clever way to handle arguments that contain commas with fpx3? ...
    (comp.lang.fortran)
  • Re: How to remove trailing commas and points from a CSV file ?
    ... which comes in the following format: ... how could I get rid of the trailing points and commas, ... Perl isn't a toolbox, but a small machine shop where you ...
    (perl.beginners)
  • Re: need help parsing file for output
    ... I have only the basic - no add-on modules except what comes with Perl ... output all numerics inside double quotes to the number inside the ... column two (top to bottom), ... # 4) ignore lines with only commas ...
    (perl.beginners)
  • Re: need help parsing file for output
    ... Is this possible with Perl 5.x.. ... output all numerics inside double quotes to the number inside the ... column two (top to bottom), ... # 4) ignore lines with only commas ...
    (perl.beginners)
  • Re: Regarding numeric literals
    ... Since a comma is a list separator in Perl, ... all commas with underscores because Perl seems to OK it. ... numeric value, it's a string value. ...
    (comp.lang.perl.misc)