Jump to content

Archived

This topic is now archived and is closed to further replies.

chery

datafeed

Recommended Posts

[!--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.





Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
[!--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]<?php
include("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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.