473,394 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

mysqldump to a csv

I am trying to create a CSV using mysqldump that will be viewed in MS Excel,
and have a formatting question.

From the command line I type:
mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=password > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.

I want to loose the table information, the "Insert into ..." text , and the
Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the
file.
Jul 19 '05 #1
8 17476

You could use the --xml switch and output to XML instead. If you need
CSV output from that, you could use an XSLT transform. If you have tons
of data, the transform could take awhile, but it would be a pretty easy
solution.

-John
Irvin Amoraal wrote:
I am trying to create a CSV using mysqldump that will be viewed in MS Excel,
and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=password > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.

I want to loose the table information, the "Insert into ..." text , and the
Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the
file.

Jul 19 '05 #2

You could use the --xml switch and output to XML instead. If you need
CSV output from that, you could use an XSLT transform. If you have tons
of data, the transform could take awhile, but it would be a pretty easy
solution.

-John
Irvin Amoraal wrote:
I am trying to create a CSV using mysqldump that will be viewed in MS Excel,
and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=password > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.

I want to loose the table information, the "Insert into ..." text , and the
Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the
file.

Jul 19 '05 #3
I believe it was Irvin Amoraal who said...
I am trying to create a CSV using mysqldump that will be viewed in MS Excel,
and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=password > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.

I want to loose the table information, the "Insert into ..." text , and the
Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the
file.


mysql -ppassword -e"select.... into outfile \"newfile.csv\" fields
terminated by \",\""

I dont know if that'll be useful if there are commas in your data

--
-----------------------------------------------------------------------------
Chris van Ophuijsen RLU #195880
us****@gnubin.com
put "HoboSong" in the subject
-----------------------------------------------------------------------------
Jul 19 '05 #4
I believe it was Irvin Amoraal who said...
I am trying to create a CSV using mysqldump that will be viewed in MS Excel,
and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=password > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.

I want to loose the table information, the "Insert into ..." text , and the
Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the
file.


mysql -ppassword -e"select.... into outfile \"newfile.csv\" fields
terminated by \",\""

I dont know if that'll be useful if there are commas in your data

--
-----------------------------------------------------------------------------
Chris van Ophuijsen RLU #195880
us****@gnubin.com
put "HoboSong" in the subject
-----------------------------------------------------------------------------
Jul 19 '05 #5
Chris,
I thought about and tried that. The "select ... into.." creates two files;
one with the table defenition, the other with the tabel data. I am concerned
about the commas.

When I tried it, it wrote the table defenition file, but not the data file.
I was unable to find out why.
Irvin Amoraal.
______________________

"HoboSong" <us****@gnubin.com> wrote in message
news:um***********@192.168.1.75...
I believe it was Irvin Amoraal who said...
I am trying to create a CSV using mysqldump that will be viewed in MS Excel, and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename tablename --user=username --password=password > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.
I want to loose the table information, the "Insert into ..." text , and the Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the file.


mysql -ppassword -e"select.... into outfile \"newfile.csv\" fields
terminated by \",\""

I dont know if that'll be useful if there are commas in your data

--
--------------------------------------------------------------------------

--- Chris van Ophuijsen RLU #195880
us****@gnubin.com
put "HoboSong" in the subject
--------------------------------------------------------------------------

---
Jul 19 '05 #6
Chris,
I thought about and tried that. The "select ... into.." creates two files;
one with the table defenition, the other with the tabel data. I am concerned
about the commas.

When I tried it, it wrote the table defenition file, but not the data file.
I was unable to find out why.
Irvin Amoraal.
______________________

"HoboSong" <us****@gnubin.com> wrote in message
news:um***********@192.168.1.75...
I believe it was Irvin Amoraal who said...
I am trying to create a CSV using mysqldump that will be viewed in MS Excel, and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename tablename --user=username --password=password > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.
I want to loose the table information, the "Insert into ..." text , and the Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the file.


mysql -ppassword -e"select.... into outfile \"newfile.csv\" fields
terminated by \",\""

I dont know if that'll be useful if there are commas in your data

--
--------------------------------------------------------------------------

--- Chris van Ophuijsen RLU #195880
us****@gnubin.com
put "HoboSong" in the subject
--------------------------------------------------------------------------

---
Jul 19 '05 #7
I'm not really keen on using XML at this time, as introduces another level
into the project I don't think I need. I will be creating the text file via
a PHP page, so if I can't do it using mysqldump, I could always do it
manually, getting the requisite data, then writing to a text file myself. I
just thought it might be easier to use mysql dump.

Irvin Amoraal.
_______________

"John" <no****@toplevel.tld> wrote in message
news:iy****************@newsread2.news.atl.earthli nk.net...

You could use the --xml switch and output to XML instead. If you need
CSV output from that, you could use an XSLT transform. If you have tons
of data, the transform could take awhile, but it would be a pretty easy
solution.

-John
Irvin Amoraal wrote:
I am trying to create a CSV using mysqldump that will be viewed in MS Excel, and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=password > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.
I want to loose the table information, the "Insert into ..." text , and the Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the file.

Jul 19 '05 #8
I'm not really keen on using XML at this time, as introduces another level
into the project I don't think I need. I will be creating the text file via
a PHP page, so if I can't do it using mysqldump, I could always do it
manually, getting the requisite data, then writing to a text file myself. I
just thought it might be easier to use mysql dump.

Irvin Amoraal.
_______________

"John" <no****@toplevel.tld> wrote in message
news:iy****************@newsread2.news.atl.earthli nk.net...

You could use the --xml switch and output to XML instead. If you need
CSV output from that, you could use an XSLT transform. If you have tons
of data, the transform could take awhile, but it would be a pretty easy
solution.

-John
Irvin Amoraal wrote:
I am trying to create a CSV using mysqldump that will be viewed in MS Excel, and have a formatting question.

From the command line I type:
> mysqldump "--where=ent_date > \"2003-07-01\"" databasename

tablename --user=username --password=password > newfilename.csv

A dumpfile is created in the expected location with the appropriate data.
I want to loose the table information, the "Insert into ..." text , and the Quotes around the fields.

Is there a way to do that with mySQL, or is there another way to create the file.

Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mangina | last post by:
Hello all. Can anyone see why this snippet of code isnt dumping the databases using mysqldump ? All the credentials are correct (changed for the purpose of this post). $host = "localhost";...
0
by: Thiko | last post by:
Hi We currently use mysqldump to dump all our db's in quick mode to one file, backup.sql. This file has come quite large. mysqldump -Aq -u root > /MySQL/backup/backup.sql I would now like...
7
by: Adam Smith | last post by:
Hope this is the right news group!! I did a server upgrade and at the same time did a mysql update from 4.0.12 to Ver 12.22 Distrib 4.0.16 mach1# mysql --version mysql Ver 12.22 Distrib...
0
by: mcstayinskool | last post by:
I'm trying to dump a bugzilla installation to a file, then restore it to a different database name (so as to test my db backup system). I use mysqldump to dump it to a file: # mysqldump -u root...
1
by: Greg.Harabedian | last post by:
I'll start off by saying I am using MySQL v4.0 and my question is...how do I get mysqldump to dump the actual binary values store in a blob? Here is an example: -- Create a test table create...
6
by: Todd Cary | last post by:
My client is using a shared server running MySQL 2.4, however the in house server is 4.1.12 with mysqldump 10.9. Is there a way to have the 10.9 version output a format that is fully compatible...
6
by: Robert Blackwell | last post by:
I want to make a scheduled task in windows to do a mysqldump. Someone gave me this .bat to run but I'm not able to get it to work. REM @echo off for /f "tokens=1" %%i in ('date /t') do set...
6
by: Antoni | last post by:
Hello, I'm trying to make a daily database backup. When executing "mysqldump - uxxx -pxxx database /home/backup/ddbb.sql -q &" the httpd server gets blocked and my site is "offline" for 30...
0
by: Pratchaya | last post by:
How can i dump (mysqldump) with skip query logging ? Now, when i run mysqldump. mysql log ( query log ) default running/keeping all in result mysqldump. It's possible ? to run mysqldump...
7
by: damezumari | last post by:
I use Windows XP and Apache. I am trying to backup a database on my local computer with the following php code: $dbname = 'ol'; $dbhost = 'localhost'; $dbuser = 'root'; $dbpass =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.