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 | [email protected] | dog |
| 77625 | 3140818 | [email protected] | cat |
| 77622 | 3140815 | [email protected] | aardvark |
| 77583 | 3140776 | [email protected] | 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|"[email protected]"|"dog"
77625|3140818|"[email protected]"|"cat"
77622|3140815|"[email protected]"|"aardvark"
77583|3140776|"[email protected]"|"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.