I would focus on finding out why some CSV files are being made wrong. An
entire line shouldn't be enclosed in its own quotes. Fixing the problem at
that end would eliminate the need to do clean up after the fact.
At 03:42 PM 5/23/05 -0500, Michael D Schleif wrote:
>How can I optimize this sub-routine for minimal processing overhead in
>those cases where it does not apply?
A way to optimize this is to realize that a valid line contains a ","
sequence whereas a bad line doesn't. You only need to test one line of each
file since it should be consistent within a file. So..
if ( substr($firstline, 0, 1) eq '"' ) { ## Quoteful file
if ( index($firstline, '","') >= 1 ) {
# it's ok
}
else {
# fix bad file
}
}
#else {} ## Non quoteful file, it's fine
If there are single column CSV's then u would have to add something to find
out how many columns there are.
--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede males"
00000100
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs