Re: From TXT to a mySQL db

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux