Re: Validate CSV file With Table in Database!!

From: Date: Thu, 13 Sep 2001 07:54:11 +0000
Subject: Re: Validate CSV file With Table in Database!!
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-67156@lists.php.net to get a copy of this message
On Thu, 13 Sep 2001 16:52, you wrote: > There is a very good reason ! > The csv file contains world currency's > The system is updated with the changed currency's only ! > The Master field contains all country currency's , this makes it > difficult because if i drop the master table and upload the csv there > will only be a few currency's! > > Thanks > Coenraad Steenkamp > > > ----- Original Message ----- > From: "David Robley" <huntsman@www.nisu.flinders.edu.au> > Newsgroups: php.general > To: "Coenraad Steenkamp" <coenraad@webserv.co.za>; > <php-general@lists.php.net> > Sent: Thursday, September 13, 2001 9:18 AM > Subject: Re: [PHP] Validate CSV file With Table in Database!! > > > On Thu, 13 Sep 2001 16:37, Coenraad Steenkamp wrote: > > > I need to compare a csv file to a table in the database but only > > > one field in the database with > > > one field in the CSV file! Comparing only one field will make it > > > much easier! When there is any change in the Database compared to > > > the CSV file , the database must then be updated or if there are no > > > such a field it must be added to the table! > > > > > > I am new in php Please help! > > > > That seems an awful lot of work, if you know that the csv is at least > > as up to date, if not more so, than the actual table. You might as > > well just drop the table and import the contents of the csv. > > > > Unless there's a good reason not to that you haven't mentioned? OK. So it sounds like you need to do something like: for each csv file line select record where table_key = csvfield_key if record found if table_other_value != csv_other_value update table with csv_value end if else (record not found) insert new record end if end for where the key might be perhaps the country name and the other value is the current currency. Am I on the right track? Does that help you any? -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA I am functioning within established parameters.

« previous php.general (#67156) next »