RE: [PHP] Uploaded CSV -> database

From: Date: Mon, 17 Oct 2005 14:44:25 +0000
Subject: RE: [PHP] Uploaded CSV -> database
Groups: php.general 
Request: Send a blank email to php-general+get-224232@lists.php.net to get a copy of this message
> -----Original Message----- > From: Jim Moseby [mailto:JMoseby@nrbindustries.com] > Sent: Monday, October 17, 2005 10:41 AM > To: 'Brian Dunning'; php-general@lists.php.net > Subject: RE: [PHP] Uploaded CSV -> database > > > > -----Original Message----- > > From: Brian Dunning [mailto:brian@briandunning.com] > > Sent: Monday, October 17, 2005 10:37 AM > > To: php-general@lists.php.net > > Subject: [PHP] Uploaded CSV -> database > > > > > > Does anyone have an example of code to process a CSV file > submitted > > via a file upload and parse it out in order to write its > > records to a > > db? > > > > > With MYSQL (assuming permissions and such are in order) You > would simply: > > $sql="load data local infile '/path/to/csv' into table > tablename fields > terminated by ','"; > I should amend this to say that the columns in your CSV file, and in the table must match for this to work. If you wanted to parse through it line by line and do it all manually, check out the fread() and explode() functions in the PHP manual. JM

« previous php.general (#224232) next »