On Wed, Aug 08, 2001 at 08:20:33PM -0700, Jonathan Leffler wrote:
> Tim Bunce wrote:
> 
> > Read the docs and take a look at the dump_results method.
> 
> It's good, but if you insert a string containing single quotes and commas, the output
> from dump_results is ambiguous.
> 
> I was messing with a data string such as:
> q{ 'How come', he said? }
> 
> The output from dump_results (DBI v1.19) with a couple of values around the string
> was:
> 
> '1',''How come', he said?','2'
> I don't think there's an unambiguous  interpretation for the output.

True. Also the dump_results method uses neat() so it'll truncate long strings.
(The docs do say: Since it uses L</neat_list> to format and edit the
string for reading by humans, it is not recomended for data transfer
applications.)

I'd be willing to add a method similar to dump_results that would be
more useful for data transfer applications if people could agree on
what it should do. I guess the obvious target should be CSV files
and 'CSV compatible quoting' (whatever that means).

Anyone fancy prototyping such a method?

> > "One call does it all" :-)
> 
> And in the darkness binds them?  :-)

:-)

> > (Umm, perhaps that should be a DBI slogan.)
> 
> Maybe - for selectall_array*().
> 
> 
> > On Tue, Aug 07, 2001 at 09:49:47PM -0500, [EMAIL PROTECTED] wrote:
> > > I'm trying come up with a fast and easy way to export all the data from a table
> > > into a file, tab delimited, but haven't alot of success with this.
> > >
> > > What is the best way to pull all the data from a table, then put into a text
> > > file and have it tab delimited for each column value:
> > >
> > > $query = qq|select * from orders|;
> > > $sth = $dbh->prepare($query);
> > > $sth->execute();
> > >
> > > open(FILE,">$export_file");
> > > while(my @rows = $sth->fetchrow_array()) {
> > > # THIS IS WHERE I SEEM TO LOOSE IT
> > >
> > > print FILE @rows . '\t;
> > >
> > > }
> > > close (FILE)
> > >
> > > I get each row into the file, but can't get the tab delimited between each
> > > column value properly and have a "\n" newline at the end of each @rows
> > >
> > > Sorry for the basic question, but something is eluding me on this??
> 
> --
> Jonathan Leffler ([EMAIL PROTECTED], [EMAIL PROTECTED])
> Guardian of DBD::Informix 1.00.PC1 -- see http://www.cpan.org/
> #include <disclaimer.h>
> 
> 

Reply via email to