Johnstone, Colin wrote:
> Gidday all,
> 
> Is a CSV a comma delimited list. If so when creating a CSV how does
> one cope with fields that have commas in them. 
> 
> An address filed for example could be written suite 2, lvl 3.
> 
> Do you write the field names out with quotes around them?
> 
> 
> 
> <start code>
> my $filename;
> $filename =
> "/home/bdweb8083m/johnstonefamily.com/cgi-bin/hp_data/participants.txt";
> 
> my @participants;
> 
> open IN, "<$filename" || die( "Cannot Open: $!" );
> while( my $line = <IN> ){
>   chomp $line;
>   push( @participants, $line );
> }
> close IN;
> 
> print "Num elements array participants = ".scalar( @participants
> )."<br>"; 
> 
> my $outString;
> $outString  = "";
> $outString .= $fields{'SelectCity'} . ",";
> $outString .= $fields{'Workshop1'} . ",";
> $outString .= $fields{'Workshop2'} . ",";
> $outString .= $fields{'Salutation'} . ",";
> $outString .= $fields{'FirstName'} . ",";
> $outString .= $fields{'LastName'} . ",";
> $outString .= $fields{'Title'} . ",";
> $outString .= $fields{'CompanyName'} . ",";
> $outString .= $fields{'CompanyAddress'} . ",";
> $outString .= $fields{'Suburb'} . ",";
> $outString .= $fields{'State'} . ",";
> $outString .= $fields{'PostCode'} . ",";
> $outString .= $fields{'PhoneNumber'} . ",";
> $outString .= $fields{'Mobile'} . ",";
> $outString .= $fields{'EmailAddress'};
> 
> #print "Out string =$outString<br>";
> 
> push( @participants, $outString );
> 
> print "Num elements array participants = ".scalar( @participants
> )."<br>"; 
> 
> #print "@participants\n\n";
> 
> open( OUTFILE, ">$filename") or die( "Cannot open file: $!");
> while( @participants ){
>   my $val = shift( @participants );
>   print OUTFILE "$val\n";
> }
> close( OUTFILE ) or die( "Cannot close file: $!");
> <end code>
> 
> Any help appreciated.
> 
> Thank You
> 
> Colin Johnstone

        Yes you would, but do you have the capabilities of having quotes in
output? If so you might want to look at one of the modules from CPAN which
creates CSV's for you.  If no quotes involved in output, you can just quote
the fields which could have commas as part of the output.

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to