Re: Re: Loading CSV data into MySQL
| From: | Thomas Seifert | Date: | Sat, 01 Feb 2003 23:44:18 +0000 |
| Subject: | Re: Re: Loading CSV data into MySQL | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-133937@lists.php.net to get a copy of this message | ||
On 01 Feb 2003 18:06:01 -0500 b-bonini@cox.net (Brian V Bonini) wrote:
> On Sat, 2003-02-01 at 16:47, Thomas Seifert wrote:
> > >
> > > I'm loading a .csv file into MySQL, done it a million times but for some
> > > reason it is scrambling the row order. All the fields are making it in
> > > correctly but the order of the rows seems to end up totally random. I've
> > > done this a million times and never saw this..
> > >
> > > Any thoughts...
> >
> > where do you take a row-order from? and HOW are you uploading it into mysql?
> > if you don't use a "order by"-clause in a select you won't have a
> > really
> > ordered result (only by accident).
>
> LOAD DATA INFILE 'file.cvs' INTO TABLE table1 FIELDS TERMINATED BY ';';
>
> the contnts of file .csv look like:
>
> 1;2002-02-01;New Dominion Pictures;Prosecutors - The Gosch Murder
> Case;Beau Parcells;Dave Stevenson (victim's husband), Lead;yes;yes;yes
> 2;2002-02-01;Coastal;Prospecting;Zoe Whitaker;Corporate
> Representative;yes;yes; 3;2002-02-01;Metro Video;Right Spirit Campaign
> (Binge Drinking PSA), - Richmond, VA;Tom Downs;Jim
> (Sailor)/Principal;yes;yes;
> 4;2002-02-01;Metro Video;Right Spirit Campaign (Binge Drinking PSA), -
> Richmond, VA;Amie Hill;Spokesperson;;;
> 5;2002-02-01;Metro Video;Unit of Action (U.S. Army);Tim Smith;Col. Mike
> Daniels (Principal);;yes;
> 6;2002-02-01;Metro Video;Colonial Williamsburg;Molly
> Larkin;Mother/Wife;;yes;
> 7;2002-02-01;Commercial;Barton Ford;Dave Hobbs;Car Salesman;yes;yes;
> 8;2002-02-01;Commercial;Barton Ford;Jackie Jackson;Customer's Wife;;;
> 9;2002-02-01;Regent Films;First Lunch;Molly Larkin;Principal;yes;yes;
> 10;2002-02-01;Skillet Productions (televisio;Welcome Home;Molly
> Larkin;Principal;yes;yes;
>
>
> etc....
>
> You'd think they would load into the db just like that right? But they
> do not. They just end up in some random order.
>
this doesn't have anything to do with php afaik.
as I said, try:
select * from table1 order by <field1> ASC
replace the <field1> with the field you have the number in (the first field in your csv).
--
Thomas Seifert
mailto:thomas.seifert@myphorum.de
http://www.MyPhorum.de