A colleague on the other side of the world sent me some output from a MySQL CLI client query in text format. She can't convert it to CSV for me or use the INTO OUTFILE
output flag to output directly to CSV. How can I convert it to CSV format? It looks like this:
+-------------+------------------+------------------------------------------+-------------+
| pet_id | pet_identity_id | identity_value | pet_species |
+-------------+------------------+------------------------------------------+-------------+
| 77626 | 3140819 | dominic_dog@example.com | dog |
| 77625 | 3140818 | missy_miauw@example.com | cat |
| 77622 | 3140815 | shelly@example.com | aardvark |
| 77583 | 3140776 | monster_moo@example.com | cow |
+-------------+------------------+------------------------------------------+-------------+
4 rows in set (0.01 sec)
I want it to look like this CSV format (either pipe- or comma-separated):
"pet_id"|"pet_identity_id"|"identity_value"|"pet_species"
77626|3140819|"dominic_dog@example.com"|"dog"
77625|3140818|"missy_miauw@example.com"|"cat"
77622|3140815|"shelly@example.com"|"aardvark"
77583|3140776|"monster_moo@example.com"|"cow"
I've found various questions which let you do this in the CLI client using the INTO OUTFILE
notation, but nothing to just convert a query sample sent to you by someone in the form you see on screen in the MySQL client.