List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 8 2001 10:14pm
Subject:Re: comma-delimited file
View as plain text  
At 9:04 AM +1100 1/9/01, Mark Dale wrote:
>>  > Hello
>>>  Could anyone tell me how to select some contents of a table and dump
>>>  them as a comma-delimited file.
>>>  Thanks
>>>  Mark Dale
>>Read The Fine Manual, look in section 7.19 and read up on
>>/ Carsten
>>Carsten H. Pedersen
>>Keeper and maintainer of the MySQL FAQ
>It seems this is only possible if you have permissions to write 
>files to the server as I get a "permission denied" error message.
>The database table I'm trying to get the file from is hosted at an ISP.
>Is there another method to get a comma-delimited file?

mysql -N -e "your query here" db_name | sed -e 's/	/,/g' > output_file

where the character after the first slash in the sed command is a tab.
You can also use this, though the sytax may vary for different versions
of the tr command:

mysql -N -e "your query here" db_name | tr '\t' , > output_file

Paul DuBois, paul@stripped
comma-delimited fileMark Dale8 Jan
  • Re: comma-delimited fileCarsten H. Pedersen8 Jan
    • Re: comma-delimited fileMark Dale8 Jan
      • Re: comma-delimited filePaul DuBois8 Jan
        • Re: comma-delimited fileMark Dale9 Jan