Databases :: MySql :: load data in file query |
|||
| By: phpsnook |
Date: 23/10/2008 09:30:04 |
Points: 20 | Status: Answered Quality : Excellent |
|
hai i am using LOAD DATA INFILE command to load a csv to the database,in a particular column i want the white spaces to be replaced ......can i use REPLACE for tht pls help |
|||
| By: VGR | Date: 23/10/2008 18:34:05 | Type : Comment |
|
| I usually LOAD DATA INFI with stupid varchar(x) columns (appropriate number of columns), and the I convert the import table to a real table doing replace(), case when..., format changes (string to numeric, saves space) etc Indeed you can't do both operations (importing and data changes) in one go using LOAD DATA INFILE. HTH |
|||
| By: ushastry | Date: 29/10/2008 11:42:57 | Type : Answer |
|
| Try this... load data local infile 'filename.csv' into table tableName fields terminated by ',' optionally enclosed by '"' lines terminated by '\r\n' ( @col1 ,@col2 ,@col3 ) set col1 = REPLACE(@col1,' ','') col2 = REPLACE(@col2,' ','') col3 = REPLACE(@col3,' ','') ; Syntax can be found here http://dev.mysql.com/doc/refman/5.0/en/load-data.html |
|||
| By: VGR | Date: 29/10/2008 17:54:36 | Type : Comment |
|
| thanks ushastry, it's true . It's available "as of MySQL 5.0.3". I suppose I've to upgrade my brain ;-) | |||
| By: ushastry | Date: 29/10/2008 18:05:03 | Type : Comment |
|
| Welcome VGR. BTW are you the VGR from experts-exchange(EE)? I'm quite familiar with this name 'VGR' & valuable solutions on the EE forums. Thanks, Umesh Shastry |
|||
| By: VGR | Date: 29/10/2008 18:57:53 | Type : Comment |
|
| yes I am, but I was active on EE.com only from Oct 2002 to Oct 2003 ;-) Since Oct 2003, we opened this (really free) site. |
|||
| By: OpConsole | Date: 03/04/2011 19:02:30 | Type : Comment |
|
| force close | |||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








