How to create a csv or excel file from a mysql query

So, every now and then you may want to have a table or some sql query as a csv or excel file to be able to do certain tasks like graphing etc.
Here a quick way to get that.

mysql -h Host -uUser -pPassword -D Database -e 'sql query;' | sed "s/'/\'/;s/\t/\",\"/g;s/^/\"/;s/$/\"/;s/\n//g" >MyFile.csv
Continue reading “How to create a csv or excel file from a mysql query”