chery Posted May 25, 2006 Share Posted May 25, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]CSV Feed Live You may retrieve the latest copy of the CSV feed at any time using the link below. This allows you to quickly save the feed from your browser or set up an automated import system to keep your database up-to-date automatically.[/quote] How do I make an automated import sytem - one that will delete all entries and replace them with the new ones - and get it to update once per day perhaps?I would appreciate any help as this one has me absolutely stumped. Quote Link to comment https://forums.phpfreaks.com/topic/10429-datafeed/ Share on other sites More sharing options...
zq29 Posted May 25, 2006 Share Posted May 25, 2006 You can parse a CSV file as easily as something like this:[code]<?php$contents = file("http://www.thewebsite.com/file.csv");foreach($contents as $line) { $line = explode(",",$line); //$line is now an array of all of the fields in the current line in the csv.}?>[/code]That code should point you in the right direction, might be worth checking out file functions in the php manual too.As for running once a day, you'd need to set up a cron job (if using *NIX) or an entry in Scheduler (if using Win). Quote Link to comment https://forums.phpfreaks.com/topic/10429-datafeed/#findComment-38876 Share on other sites More sharing options...
chery Posted May 25, 2006 Author Share Posted May 25, 2006 [!--quoteo(post=376987:date=May 25 2006, 08:03 AM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 25 2006, 08:03 AM) [snapback]376987[/snapback][/div][div class=\'quotemain\'][!--quotec--]You can parse a CSV file as easily as something like this:[code]<?php$contents = file("http://www.thewebsite.com/file.csv");foreach($contents as $line) { $line = explode(",",$line); //$line is now an array of all of the fields in the current line in the csv.}?>[/code]That code should point you in the right direction, might be worth checking out file functions in the php manual too.As for running once a day, you'd need to set up a cron job (if using *NIX) or an entry in Scheduler (if using Win).[/quote]Does this look right?[code]<?phpinclude("db.php");mysql_connect($db_host, $db_user, $db_pwd);mysql_select_db($db_name);$contents = file("http://dc1datafeed.regnow.com/srv/rs.aspx?&afid=54516");foreach($contents as $line) { $line = explode(",",$line); //$line is now an array of all of the fields in the current line in the csv.}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10429-datafeed/#findComment-38887 Share on other sites More sharing options...
Barand Posted May 26, 2006 Share Posted May 26, 2006 You might want to look up LOAD DATA INFILE = 'xxxx' command in the MySQL manual. It's much faster than parsing a CSV line by line Quote Link to comment https://forums.phpfreaks.com/topic/10429-datafeed/#findComment-39174 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.