Try Text::CSV_XS;



                                                                                       
                                      
                    Jones Robert Contr 81 CS/SCK                                       
                                      
                    <[EMAIL PROTECTED]>               To:     
[EMAIL PROTECTED]           
                    Sent by:                                     cc:                   
                                      
                    [EMAIL PROTECTED]        Subject:     Reading 
from SQL, Writing to CSV ...           
                    eState.com                                                         
                                      
                                                                                       
                                      
                                                                                       
                                      
                    03/21/01 04:18 PM                                                  
                                      
                                                                                       
                                      
                                                                                       
                                      



           I'm running the following snippet of code below.  Every time I
read
a field in that has a series of alpha with commas in it there are problems.
After each of these multiple comma fields is read, the next field is
skipped.  For example, if a field contains 'john, henry, III' then my next
field is omitted.

           Are there any characters which when read into a list will screw
it
up ??


while (@import=$sth->fetchrow_array)
 {
  $count++;
  $tmpcount = 0;
  foreach $holder (@import)
   {
    $tmpcount++;
    $ota[$count][$tmpcount] = $holder;
   }
 }

open(FHCSV, "> ota.csv") || die "Ouch !!!\n $!\n";
for ($xx=1; $xx <= $count; $xx++)
 {
  for ($yy=1; $yy <= $tfields-1; $yy++)
   {
    if ($ota[$xx][$yy] =~ /\,/)
     { print FHCSV "\"$ota[$xx][$yy],\""; }
    else
     { print FHCSV "$ota[$xx][$yy],"; }
   }
  if ($ota[$xx][$tfields] =~ /\,/)
   { print FHCSV "\"$ota[$xx][$tfields]\"\n"; }
  else
   { print FHCSV "$ota[$xx][$yy]\n"; }
 }
close(FHCSV);


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users




_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to