Pedro Assunção

Export Mysql result as CSV

Don’t ask me how the sed magic works, but it does. Taken from here.

Running this:

mysql -u<USER> -p<PASSWORD> <DATABASE> -B -e "select * from videos_video;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g'

will produce something like this:

"id","title","url"
"1","video 1","http://youtube(...)"
"2","video 2","http://youtube(...)"
"3","video 3","http://youtube(...)"

Just pipe it to a .csv file and you’re done :)

Related:

  1. How to export HD video for the web As some of the people who know me are aware,...
  2. Video speed controls on youtube’s HTML5 player I don’t know if you noticed, but youtube introduced speed...


Categorised as: computers, findings, software development, tips


Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>