Re: From TXT to a mySQL db
| From: | Jason Pruim | Date: | Thu, 18 Oct 2007 18:38:10 +0000 |
| Subject: | Re: From TXT to a mySQL db | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263325@lists.php.net to get a copy of this message | ||
On Oct 18, 2007, at 2:29 PM, Marcelo Wolfgang wrote:
Hi all, I need some helps/tips to know if a transition from a txt file to a sql database is viable to do. I have a TXT file that has lots of records like this: 10^13150^COMERCIO DE CALCADOS DILEU LTDA^COMERCIO DE CALCADOS DILEU LTDA^RUA JOSE BONIFACIO, 329^CENTRO^IJUI^RS^98700000^055 3325409^ 10^13169^ZILMAR DE PARIS^ZILMAR DE PARIS^MARECHAL FLORIANO1151^CENTRO^SOLEDADE^RS^99300000^ 54 3812166^ 20^9833^90700^ELLA VERAO 2007^90702^COURO SOFT^BCO 20^9833^90700^ELLA VERAO 2007^90702^COURO SOFT^PRETO The rows that start with 10 are one kind of data and the rows that start with 20 are another kind of data, each will go to its own table (there's a lots of 10's and lots of 20's). The first set of data, the ones that start with 10 its table structure will look like this (the 10 will be discarded): id - number name - text altName - text address - text neighbour - text city - text state - text cep - number tel - text mail - text the second one with the rows that start with 20 its structure will be like this ( again the 20 will be discarded ) idClient - number brand - text idLine - number descLine - text ref -number material - text color - text Is there a quick and simple way to convert the row string into a INSERT query ? Should I try some manipulation first with the TXT file ?I think what you are looking for is the "LOAD DATA" command. With that one of the options is "SEPARATED BY" I'd do a search for "LOAD DATA" in the mysql site. -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com japruim@raoset.com