FatDog has asked for the wisdom of the Perl Monks concerning the following question:
Here is the problem: many of the rows have free-text comment blocks with commas that are delimited by double-quotes like this:my (@Cols) = split (",", $lRow);
How do I remove all commas if they are between ," and ", bracketing pairs?1123,,,"10.11.12.13",4,"I really, really wanted",,,"It was, like great +" 1123,,,"34.123.12.12",8,"Fantastic",,,"",,
Note: I dont have to preserve the free-text comments. Is there a regrex to detect & replace everything between: ," and ", if there is a comma with ,"",? The problem is: things like IP addresses and email address are also enclosed in " characters and I need to preserve them. Another problem, some people put multiple comma's in their comments like: "It was ,,,,, the worst experience of my life"
Note: I can make multiple passes through the row so I have thought about replacing all ," combinations with ,| combinations and all ", combinations with |, then replacing everything between two || chars with "".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help parsing comma-delimited file
by jZed (Prior) on May 20, 2004 at 23:30 UTC | |
|
Re: Need help parsing comma-delimited file
by pizza_milkshake (Monk) on May 20, 2004 at 22:40 UTC | |
by FatDog (Beadle) on May 20, 2004 at 22:50 UTC | |
|
Re: Need help parsing comma-delimited file
by Nkuvu (Priest) on May 20, 2004 at 22:06 UTC |