<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
For future reference you can force Text::CSV to always quote every
field by setting 'always_quote' to true:<br>
<br>
<tt>my $csv = Text::CSV->new({ always_quote => 1});</tt><br>
<br>
or for an already instantiated csv object:<br>
<br>
<tt>$csv->always_quote(1);</tt><br>
<br>
Cheers,<br>
<br>
Mark<br>
<br>
<div class="moz-cite-prefix">On 10/15/2012 8:14 PM, Chris Jones
wrote:<br>
</div>
<blockquote cite="mid:20121016001433.A3A4D11EFB5@xx1.develooper.com"
type="cite">It is all working great. Thanks for your help!
<br>
I am using DBI ADO and Text::CSV.
<br>
<br>
Text::CSV adds quotes where needed. I was trying to get the same
output as ms access which quotes all text fields whether they
contain white space or not. For reading in to excel, the quotes
on text fields are not necessary unless there is a white space,
new line, etc. in the field.
<br>
<br>
It works slick. Much better than opening each file in Access and
exporting to csv.
<br>
<br>
<br>
<br>
At 04:49 PM 15/10/2012, Chris Jones wrote:
<br>
<blockquote type="cite">Thank you! It works well except I can't
get quotes around Text fields.
<br>
<br>
I am using:
<br>
my $csv = Text::CSV->new ( { binary => 1 } ) # should set
binary attribute.
<br>
or die "Cannot use CSV:
".Text::CSV->error_diag ();
<br>
<br>
$csv->types ([Text::CSV::IV (),
<br>
Text::CSV::IV (),
<br>
Text::CSV::PV (),
<br>
Text::CSV::PV (),
<br>
Text::CSV::PV (),
<br>
Text::CSV::PV (),
<br>
Text::CSV::IV (),
<br>
Text::CSV::IV ()]);
<br>
<br>
#output database results
<br>
while (my @row=$sth->fetchrow_array)
<br>
{
<br>
#my $line = join( ",", @row );
<br>
print "@row\n";
<br>
my $status = $csv->combine(@row);
<br>
my $line = $csv->string();
<br>
print "$line\n"
<br>
<br>
}
<br>
<br>
The output has quotes around the memo fields but the text fields
are not quoted?
<br>
<br>
At 09:21 AM 15/10/2012, Shlomi Fish wrote:
<br>
<blockquote type="cite">Hi Chris,
<br>
<br>
On Mon, 15 Oct 2012 09:07:39 -0400
<br>
Chris Jones <a class="moz-txt-link-rfc2396E" href="mailto:cj@enersave.ca"><cj@enersave.ca></a> wrote:
<br>
<br>
> Thank you.
<br>
>
<br>
> I have written a perl script using DBI ADO. The
<br>
> select and print statements work. I am using the
<br>
> join statement to separate the fields by ',' but
<br>
> I can't figure out a way to get the text fields
<br>
> quoted so the output resembles the CSV output by
msaccess.
<br>
>
<br>
> Example output from access:
<br>
> 240,10,"SPACE:LGT-W/A[1]","if( Local( ZONE-TYPE )
<br>
> == 1 then 1 endif","Set lighting power","8.4.4.6","db
2012-04-19 -
<br>
> added",1,0
<br>
>
<br>
> The field types:
<br>
> number, number, text, memo, text, text, memo, integer,
integer.
<br>
>
<br>
> The output from my script:
<br>
>
<br>
> 240,10,SPACE:LGT-W/A[1],if( Local( ZONE-TYPE ) ==
<br>
> 1 then 1 endif,Set lighting power,8.4.4.6,db 2012-04-19 -
added,1,0
<br>
>
<br>
> Thanks for any insight!
<br>
<br>
Please use <a class="moz-txt-link-freetext" href="https://metacpan.org/module/Text::CSV">https://metacpan.org/module/Text::CSV</a> to output CSV
(as well
<br>
as read it). Read its documentation for configurations options
that control
<br>
the resultant output.
<br>
<br>
Regards,
<br>
<br>
Shlomi Fish
<br>
<br>
--
<br>
-----------------------------------------------------------------
<br>
Shlomi Fish <a class="moz-txt-link-freetext" href="http://www.shlomifish.org/">http://www.shlomifish.org/</a>
<br>
My Aphorisms - <a class="moz-txt-link-freetext" href="http://www.shlomifish.org/humour.html">http://www.shlomifish.org/humour.html</a>
<br>
<br>
“My only boss is God. And Chuck Norris who is his boss.â€
<br>
<br>
Please reply to list if it's a mailing list post -
<a class="moz-txt-link-freetext" href="http://shlom.in/reply">http://shlom.in/reply</a> .
<br>
</blockquote>
<br>
>>
<br>
Christopher Jones, P.Eng.
<br>
Suite 1801, 1 Yonge Street
<br>
Toronto, ON M5E1W7
<br>
Tel. 416-203-7465
<br>
Fax. 416-946-1005
<br>
email <a class="moz-txt-link-abbreviated" href="mailto:cj@enersave.ca">cj@enersave.ca</a>
<br>
<br>
_______________________________________________
<br>
toronto-pm mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://mail.pm.org/mailman/listinfo/toronto-pm">http://mail.pm.org/mailman/listinfo/toronto-pm</a>
<br>
</blockquote>
<br>
>>
<br>
Christopher Jones, P.Eng.
<br>
Suite 1801, 1 Yonge Street
<br>
Toronto, ON M5E1W7
<br>
Tel. 416-203-7465
<br>
Fax. 416-946-1005
<br>
email <a class="moz-txt-link-abbreviated" href="mailto:cj@enersave.ca">cj@enersave.ca</a>
<br>
<br>
_______________________________________________
<br>
toronto-pm mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://mail.pm.org/mailman/listinfo/toronto-pm">http://mail.pm.org/mailman/listinfo/toronto-pm</a>
<br>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<p style="font-size: 10px; font-family: arial, helvetica,
sans-serif; color: #3C5678;">Mark Jubenville <a
href="mailto:ioncache@gmail.com" style="color: #3C5678;">ioncache@gmail.com</a></p>
</div>
</body>
</html>