Jump to content


Photo

displaying contents of remote csv file


  • Please log in to reply
3 replies to this topic

#1 Malkavbug

Malkavbug
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 03 May 2006 - 06:02 PM

:)

Here is what I am trying to do, but I cannot find a tutorial on how to do it since I am dealing with a CSV file with multiple rows but only one column

When a user visits the page I want php to grab
[a href=\"http://finance.yahoo.com/d/quotes.csv?s=SOFO+LNUX&f=l1\" target=\"_blank\"]http://finance.yahoo.com/d/quotes.csv?s=SOFO+LNUX&f=l1[/a]

Which contains
SOFO_Current_Price
LNUX_Current_Price

This is expandable (i can add more symbols to the URL) so what I am trying to do is make a script that will fetch that file, grab each line assigning it a variable in sequence to later print, ie $stock1 $stock2 etc so later on in my table where I want to print the information I only have to add
<?php echo "$stock1" ?>
to get it to display the data, in this case to simple print out SOFO_Current_Price

If anyone knows a good way to do this I would appreciate it. Current Price is all I need and I am trying to write this with as little code as possible, which should be possible, I just don't know how to interact with CSV rows assigning a variable for each row of data.



#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 03 May 2006 - 06:07 PM

fopen() with fread() should get you headed in the right direction.

Info: PHP Manual


#3 Malkavbug

Malkavbug
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 03 May 2006 - 06:16 PM

Thanks, will dig through those :)

#4 Malkavbug

Malkavbug
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 03 May 2006 - 07:13 PM

Oka think i got it, renamed some variables to make it read better

Please tell me what you think and if the code is good or could be better.

(removed, seeing if it will let me post, getting an error)

Well, I think I have a solution but it will not let me post code for some reason.....




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users