in reply to Recommendations for parsing invalid CSV
The 2nd line is input, the 3rd output.user@machine$ perl -pe 's/(?<=.)(?<!,)"(?!,|$)/\\"/g' "call from "friend"","call from "friend"","call from "friend"" "call from \"friend\"","call from \"friend\"","call from \"friend\""
Looks good for me. Some special cases with escaped commas inside the strings might not match correctly. You should check this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Recommendations for parsing invalid CSV
by markjugg (Curate) on Apr 21, 2008 at 15:24 UTC |