in reply to Re: One Liner to double quote every field in a delimited fle (Updated!)
in thread One Liner to double quote every field in a delimited file

It's a common mistake to forget to escape literal occurrences of the same character used to "quote" fields.

Windowsish

perl -pe "s{(?=\")}{\"}g; s{,}{\",\"}g; s{^}{\"}; s{$}{\"};" infile.csv > outfile.csv

Unixish

perl -pe 's{(?=")}{"}g; s{,}{","}g; s{^}{"}; s{$}{"};' infile > outfile

Replies are listed 'Best First'.
Re^3: One Liner to double quote every field in a delimited fle (Updated!)
by BrowserUk (Patriarch) on Feb 02, 2014 at 08:28 UTC
    It's a common mistake to forget to escape literal occurrences of the same character used to "quote" fields.

    I didn't forget.

    I just didn't make the mistake of over-engineering a one-liner to cater for unspecified requirements.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.