Posted on Thu 1st Jul 2010 · Development · 0 Comments
Today at work I had the amazing job of importing around 50 different artists profiles in to a database - each with about 12 different columns of values in a CSV file.
I could copy & paste it from the document - or create a quick little import script... Yea, I made an import script :]
<?php
$file_handle = fopen("file.csv", "r");
while (!feof($file_handle)) {
$data = fgetcsv($file_handle, 1024);
## PARSE THE VALUES OF EACH CELL
## STARTING AT 0 AND WORK YOUR WAY ALONG
$data[0].'<br />';
$data[1].'<br />';
$data[2].'<br />';
$data[3].'<br />';
## AND SO ON...
}
fclose($file_handle);
?>