[Bast-commits] r8167 - ironman/IronMan-Web/script

iain at dev.catalyst.perl.org iain at dev.catalyst.perl.org
Thu Dec 24 11:34:45 GMT 2009


Author: iain
Date: 2009-12-24 11:34:45 +0000 (Thu, 24 Dec 2009)
New Revision: 8167

Modified:
   ironman/IronMan-Web/script/import_csv.pl
Log:
removed debug, added some pod and support for summary field

Modified: ironman/IronMan-Web/script/import_csv.pl
===================================================================
--- ironman/IronMan-Web/script/import_csv.pl	2009-12-24 11:03:15 UTC (rev 8166)
+++ ironman/IronMan-Web/script/import_csv.pl	2009-12-24 11:34:45 UTC (rev 8167)
@@ -5,8 +5,14 @@
 use utf8 ();
 =head1 import_csv.pl
 
-this script is a one hit import from the "old" csv file to the new feed db
+This script is a one hit import from the "old" csv file to the new feed db. 
 
+It is safe to run multiple times on the same data.
+
+All you need to do is fill in the correct paths to your csv files and subscriptions.db
+
+A file called problems.txt will be generated with .... problems, usually missing dates.
+
 =cut
 use Data::Dumper;
 
@@ -14,8 +20,10 @@
 use Text::CSV_XS;
 use DateTime::Format::HTTP;
 
-my @files = </data/Projects/ironman/csv/*>;
-my $schema = IronMan::Schema->connect('dbi:SQLite:/data/Projects/ironman/subscriptions.db');
+# UPDATE THESE PATHS #
+die "UPDATE YOUR PATHS AND REMOVE THIS LINE";
+my @files = </home/iain/Projects/ironman/csv/*>;
+my $schema = IronMan::Schema->connect('dbi:SQLite:/home/iain/Projects/ironman/subscriptions.db');
 
 print scalar(@files),"\n";
 
@@ -66,10 +74,6 @@
         
         while (my $row = $csv->getline ($fh)) {
 
-            if($row->[1] eq 'We Are Iron Man') {
-                $schema->storage->debug(1);
-            }
-            
             unless($row->[3]) {
                 print PROBLEMS "no date found for post:$row->[1], file:$file\n";
                 next;       
@@ -94,6 +98,7 @@
                     $post->update({
                         title     => $row->[1],
                         url       => $row->[2],
+                        summary   => $row->[4],
                     });
                      
                     # track the most recent post date
@@ -121,6 +126,7 @@
                             tags      => '',
                             posted_on => $new_date,
                             body      => '',
+                            summary   => $row->[4],
                         }
                     );
                 };
@@ -134,10 +140,9 @@
                             tags      => '',
                             posted_on => $new_date->datetime(),
                             body      => '',
+                            summary   => $row->[4],
                         });
-            if($row->[1] eq 'We Are Iron Man') {
-                die;    
-            }
+
                         next;    
                 }
                 




More information about the Bast-commits mailing list