Permalink
Browse files

Initial Commit

  • Loading branch information...
0 parents commit 14eaaa870d933117249826fc4f7c3cd7f4c5ab5a @shantanugoel shantanugoel committed Feb 7, 2011
Showing with 48 additions and 0 deletions.
  1. +48 −0 shantz-csv-to-opml.pl
@@ -0,0 +1,48 @@
+#!perl -w
+#shantz-csv-to-opml.pl - Made by Shantanu Goel http://tech.shantanugoel.com http://blog.shantanugoel.com
+#Usage: shantz-csv-to-opml.pl <input file in csv format> <output opml filename>
+#Input File Format:
+#Each line should be like this:
+#<Name of Author>,<bloglink>,<bloglink>...
+#e.g.
+#Shantanu Goel, http://tech.shantanugoel.com, http://blog.shantanugoel.com
+#There can be any number of blogs for any author, if blogs are more than one, then multiple entries for that author will be made in opml file each indexed with increasing number like Shantanu Goel 1, Shantanu Goel 2, etc
+#Version History:
+#0.1 - Initial Version
+#Visit the script homepage for questions and updates (Also check out other cool stuff)
+#Script Homepage: http://tech.shantanugoel.com/projects/misc-stuff/shantz-csv-to-opml
+use strict;
+
+my $input = shift @ARGV;
+my $output = shift @ARGV;
+
+open INPUT, "< $input" or die "Can't open $input:$!";
+open OUTPUT, "> $output" or die "Can't open $output:$!";
+
+print OUTPUT <<Header;
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- OPML generated by shantz-csv-to-opml.pl -->
+<opml version="1.1">
+<head>
+<title>My blogroll</title>
+<dateModified></dateModified>
+<ownerName>Blogroll Owner</ownerName>
+<ownerEmail>Owner Email</ownerEmail>
+</head>
+<body>
+Header
+while (<INPUT>)
+{
+ chomp;
+ s/\s*$//;
+ s/\"//g;
+ my @line = split /,/;
+ for (my $i = 1; $i <= $#line; ++$i)
+ {
+ print OUTPUT "<outline text=\"$line[0]";
+ print OUTPUT " $i" if ($#line > 1);
+ print OUTPUT "\" type=\"link\" url=\"$line[$i]\" target=\"_blank\" />\n"
+ }
+}
+close INPUT;
+print OUTPUT "</body>\n</opml>";

0 comments on commit 14eaaa8

Please sign in to comment.