469,953 Members | 2,235 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,953 developers. It's quick & easy.

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 17269

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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mangina | last post: by
reply views Thread by Thiko | last post: by
7 posts views Thread by Adam Smith | last post: by
reply views Thread by mcstayinskool | last post: by
1 post views Thread by Greg.Harabedian | last post: by
6 posts views Thread by Todd Cary | last post: by
6 posts views Thread by Robert Blackwell | last post: by
6 posts views Thread by Antoni | last post: by
7 posts views Thread by damezumari | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.