I have an ongoing stream of CSV files of varying lengths (some quite
long), and of various CSV formats.  I am using Text::CSV_XS to parse the
records; which works except in that case where the incoming file
surrounds each RECORD with double-quotes.

I find this to be aberrant behaviour.  How can I tell Text::CSV_XS to
ignore double-quotes around records?

I have the following code that normalizes each line prior to parsing
with Text::CSV_XS:

    if (
             /^"/
        &&   /"$/
        && tr/"// == 2
    ){
        s!(^"|"$)!!g;
    }

Obviously, in the majority of cases this should be a no-op, since
double-quotes surround fields, NOT records.

How can I optimize this sub-routine for minimal processing overhead in
those cases where it does not apply?

-- 
Best Regards,

mds
mds resource
877.596.8237
-
Dare to fix things before they break . . .
-
Our capacity for understanding is inversely proportional to how much
we think we know.  The more I know, the more I know I don't know . . .
--

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to