List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:June 27 1999 1:44am
Subject:Re: Exporting to Comma Delimited
View as plain text  
In the last episode (Jun 25), Paul Stewart said:
> Hi there.. I have a copy of the DMOZ database loaded onto a computer
> in Mysql.  I'd like to export a certain portion or the entire thing
> (either way is managable but certain portion works better for me) to
> a comma delimited file.
> 
> Granted that I know the names of the fields I want to export, can
> someone tell me how to do this hopefully simple task?

If you know there are no commas in any fields, the quickest way is
probably:

mysql -r --skip-column-names -e "select * from table" database | tr "\t" ","

If you can handle a tab-delimited file, just omit the tr command.  If
you absolutely need comma-delim and there might be commas in the fields
(but you know there are no quotes), try:

mysql -r --skip-column-names -e "select concat(field1,'\",\"',
		field2,'\",\"',field3) from table" database


	-Dan Nelson
	dnelson@stripped
Thread
Exporting to Comma DelimitedPaul Stewart27 Jun
  • Re: Exporting to Comma DelimitedDan Nelson27 Jun
  • Re: Exporting to Comma DelimitedJorge del Conde27 Jun
  • Re: Exporting to Comma DelimitedPat Sherrill27 Jun