Re: Re: Loading CSV data into MySQL
| From: | Brian V Bonini | Date: | Sat, 01 Feb 2003 23:06:01 +0000 |
| Subject: | Re: Re: Loading CSV data into MySQL | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-133932@lists.php.net to get a copy of this message | ||
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.