Adsense 1

Showing posts with label CSV. Show all posts
Showing posts with label CSV. Show all posts

Wednesday, August 23, 2006

Converting Mysql table to CSV

Trying to export the data from mysql to csv will end up in creating the csv file in the mysql data directory (/var/lib/mysql). Use this method to covert the individual tables from mysql to CSV format

$mysql -u <username> -h <hostname> <databasename> -p -B -e "select * from table;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > test.csv

Note: The whole command above must essentially be in a single line