Results 1 to 5 of 5
  1. #1
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    convert csv to rss feed?
    I'm looking for a program / script to convert some csv files into an rss feed. Did a google search and found several that convert to xml or convert rss into csv, but not what I'm needing.

    ideas?
    Someday starts today
    Military Discounts

  2. #2
    Full Member
    Join Date
    October 22nd, 2006
    Posts
    200
    No but I've got one that creates an RSS file from a mysql database.

    With bit of tweaking you should be able to get it working with csv.

    PHP Code:
    <?php
    $link 
    mysql_connect("localhost""user""pass")
       or die(
    "Could not connect : " mysql_error());
      
    mysql_select_db("database") or die("Could not select database");
    $xml='<?xml version="1.0" encoding="utf-8"?>'."\r\n";
    $xml.='<rss version="2.0">'."\r\n";
    $xml.='<channel>'."\r\n";
    $xml.='<title>Your title</title>'."\r\n";
    $xml.='<link>http://www.yourwebsite.com</link>'."\r\n";
    $xml.='<description>feed description.</description>'."\r\n";
    $xml.='<language>en-US</language>'."\r\n";
    $xml.='<pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>'."\r\n";
    $xml.='<lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>'."\r\n";
    $xml.='<docs>http://blogs.law.harvard.edu/tech/rss</docs>'."\r\n";
    $xml.='<managingEditor>editor@example.com</managingEditor>'."\r\n";
    $xml.='<webMaster>webmaster@example.com</webMaster>'."\r\n";
    $sql ="SELECT * FROM flash ORDER by plays DESC LIMIT 10";
    $result=mysql_query($sql);
    while (
    $line=mysql_fetch_assoc($result)){
    $xml.='<item>'."\r\n";
    $xml.='<title>'."\r\n";
    $xml.=$line['name'];
    $xml.='</title>'."\r\n";
    $xml.='<description><![CDATA['."\r\n";
    $xml.=$line['short_description'];
    $xml.=']]></description>'."\r\n";
    $xml.='<enclosure url="'.$line['image_url'].'" type="image/jpeg" />';
    $xml.='<link>'.$line['product_url']'."</link>'."\r\n";
    $xml.='</item>'."\r\n";
    }
    $xml.='</channel>'."\r\n";
    $xml.='</rss>'."\r\n";
    header("Content-type: application/xml");    
    header('Content-Disposition:  filename="filename.xml"');
    echo 
    $xml;
    ?>
    You just need to use $fp=fopen("file.csv")
    Change the while loop to while ($data=fgetcsv($fp,8192,",")){
    and use $data[0], $data[1] etc in place of $line['name'] etc
    and finally fclose($fp);

    The enclosure tag is optional and is only used by a few rss readers.

  3. #3
    Affiliate Manager
    Join Date
    January 18th, 2005
    Location
    Los Angeles, California
    Posts
    1,911
    Do you want to do the whole feed, or select specific records from it?
    Richard Gaskin
    Developer of WebMerge: Publish any data feed on any site
    http://www.fourthworld.com

  4. #4
    Believe knight01's Avatar
    Join Date
    August 14th, 2006
    Location
    Dayton, Ohio
    Posts
    1,815
    Quote Originally Posted by FourthWorld
    Do you want to do the whole feed, or select specific records from it?
    Richard,
    At this point I'm trying to convert an entire csv file. I can see where it might be nice to create the feed based on a keyword(s). But this isn't a datafeed of products, it's actually geographic content for a site.
    Someday starts today
    Military Discounts

  5. #5
    Affiliate Manager
    Join Date
    January 18th, 2005
    Location
    Los Angeles, California
    Posts
    1,911
    When do you need it?
    Richard Gaskin
    Developer of WebMerge: Publish any data feed on any site
    http://www.fourthworld.com

+ Reply to Thread

Similar Threads

  1. Csv To Rss Feeds
    By National Discount Stores in forum ShareASale - SAS
    Replies: 11
    Last Post: November 28th, 2008, 08:24 AM
  2. convert datafeeds to rss
    By topten in forum ShareASale - SAS
    Replies: 2
    Last Post: November 15th, 2005, 01:30 AM
  3. Easiest way to convert datafeeds in RSS
    By mika in forum Programming / Datafeeds / Tools
    Replies: 2
    Last Post: June 15th, 2005, 11:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •