reading a csv file
Posted: Tue Feb 08, 2011 12:19 pm
hi,
i am trying to read a csv file at the location $url using the following code, but it is not able to open the handle... it goes into the else statement and prints "error" ... can any one please help ?
i am trying to read a csv file at the location $url using the following code, but it is not able to open the handle... it goes into the else statement and prints "error" ... can any one please help ?
Code: Select all
echo $stock_list;
if (! $stock_list) {
$stock_list = "^IXIC,^DJA,^NIN,^FTSE";
}
$url = "http://quote.yahoo.com/d/quotes.csv?s=" . $stock_list . "&f=nl1c1& =.csv";
echo $url;
$filesize = 2000;
if(($handle = fopen($url, "r"))!=FALSE)
{
echo "\n handle = ";
echo $handle;
$raw_quote_data = fread($handle, $filesize);
echo $raw_quote_data;
echo $url;
fclose($handle);
}
else
{
echo "failure";
}