getting data out: mysql -> csv

Scott Elcomb psema4-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Tue May 29 21:47:57 UTC 2007


On 5/29/07, Ian Petersen <ispeters-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> On 5/29/07, Emma Jane Hogbin <emmajane-MHIYrZpDPrNWk0Htik3J/w at public.gmane.org> wrote:
> > how do you get HTML fragments (especially
> > when there are new lines, tabs and quotes as part of the data) out of a
> > MySQL table and into a CSV?
>
> There are probably lots of ways to do it, but my choice would be to
> write a script in Ruby to connect to the database and output CSV to
> stdout.  Ruby has a CSV module that supports escaping characters and
> so on.  If you like, you could even use ActiveRecord to connect to
> your database, but that might be overkill.  There's probably an
> equivalent way to do it in Perl but I'm not familiar with it.

There's at least one that I know of, but it's not "clean" and should
not really be considered for production use.  A set of modules I've
been working on, SAL, (see http://gtalug.org/wiki/SAL for some
incomplete documentation) is capable of exporting to CSV relatively
quickly.

Whether it is capable of doing what you need out-of-the-box is
somewhat questionable however.  Best of luck!

-- 
Scott Elcomb

"Our Founders' faith in the viability of representative democracy
rested on their trust in the wisdom of a well-informed citizenry,
their ingenious design for checks and balances, and their belief that
the rule of reason is the natural sovereign of a free people." - Al
Gore (The Assault on Reason, 2008)

"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."  - Benjamin Franklin

'"A lie can travel halfway around the world while the truth is putting
on its shoes."  - Mark Twain
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list