dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

how to escape new lines using select * into outfile - mysql

This is a discussion on how to escape new lines using select * into outfile - mysql ; Hi all, I want to export the values based on the condition. I export them as csv. select * into outfile 'filename.csv' from table; the problem is one field in table has many lines, means with \n. I couldn't import ...


Home > Database Forum > Other Databases > mysql > how to escape new lines using select * into outfile

Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 05-13-2008, 01:26 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default how to escape new lines using select * into outfile

Hi all,

I want to export the values based on the condition. I export them as csv.

select * into outfile 'filename.csv' from table;

the problem is one field in table has many lines, means with \n. I couldn't import the values into the xls sheet.

any ideas how to escape the new line characters?

Thanks,
Saravanan



Reply With Quote
  #2  
Old 05-13-2008, 01:57 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default RE: how to escape new lines using select * into outfile

So far as I've been able to figure out, there's no form of escaping that
will convince Excel to do what you want.

The only thing I can think of is to replace * with a list of fields, and use
MySQL functions to replace the \n with something else.

Regards,

Jerry Schwartz
The Infoshop by Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341

www.the-infoshop.com
www.giiexpress.com
www.etudes-marche.com

>-----Original Message-----
>From: Saravanan [mailto:suzuki_babu@yahoo.com]
>Sent: Tuesday, May 13, 2008 1:26 PM
>To: mysql
>Subject: how to escape new lines using select * into outfile
>
>Hi all,
>
>I want to export the values based on the condition. I export them as
>csv.
>
>select * into outfile 'filename.csv' from table;
>
>the problem is one field in table has many lines, means with \n. I
>couldn't import the values into the xls sheet.
>
>any ideas how to escape the new line characters?
>
>Thanks,
>Saravanan
>
>
>
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe: http://lists.mysql.com/mysql?unsub=jschwartz@the-
>infoshop.com





Reply With Quote
  #3  
Old 05-13-2008, 03:05 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: how to escape new lines using select * into outfile

Try using:

select * into outfile 'filename.csv' fields enclosed by '"' terminated by
',' lines terminated by '\n' from table

Regards,

Velen


----- Original Message -----
From: "Saravanan"
To: "mysql"
Sent: Tuesday, May 13, 2008 9:26 PM
Subject: how to escape new lines using select * into outfile


> Hi all,
>
> I want to export the values based on the condition. I export them as csv.
>
> select * into outfile 'filename.csv' from table;
>
> the problem is one field in table has many lines, means with \n. I

couldn't import the values into the xls sheet.
>
> any ideas how to escape the new line characters?
>
> Thanks,
> Saravanan
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=velen@biz-mu.com
>
>


Reply With Quote
  #4  
Old 05-13-2008, 03:23 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: how to escape new lines using select * into outfile

thanks velen. But I want to escape the newlines in the fields. It is annoying and new lines moves the values in separate line of excel sheet.

Thanks,
Saravanan


--- On Wed, 5/14/08, Velen wrote:

> From: Velen
> Subject: Re: how to escape new lines using select * into outfile
> To: suzuki_babu@yahoo.com
> Cc: mysql@lists.mysql.com
> Date: Wednesday, May 14, 2008, 1:35 AM
> Try using:
>
> select * into outfile 'filename.csv' fields
> enclosed by '"' terminated by
> ',' lines terminated by '\n' from table
>
> Regards,
>
> Velen
>
>
> ----- Original Message -----
> From: "Saravanan"
> To: "mysql"
> Sent: Tuesday, May 13, 2008 9:26 PM
> Subject: how to escape new lines using select * into
> outfile
>
>
> > Hi all,
> >
> > I want to export the values based on the condition. I

> export them as csv.
> >
> > select * into outfile 'filename.csv' from

> table;
> >
> > the problem is one field in table has many lines,

> means with \n. I
> couldn't import the values into the xls sheet.
> >
> > any ideas how to escape the new line characters?
> >
> > Thanks,
> > Saravanan
> >
> >
> >
> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe:

> http://lists.mysql.com/mysql?unsub=velen@biz-mu.com
> >
> >

>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=s...babu@yahoo.com




Reply With Quote
  #5  
Old 07-01-2009, 03:10 PM
Database Newbie
 
Join Date: Jul 2009
Posts: 1
klk26klk26 is on a distinguished road
Default Re: how to escape new lines using select * into outfile

Saravanan,

Did you find a way to do this, I too am trying to export data from mySQL into excel and continue to get new line characters where they shouldn't be.

Thanks!
Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 05:05 AM.