From: lingutln Date: Wed, 24 Apr 2013 22:43:11 +0000 (+0000) Subject: Deleted X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=d7056c4d41291abacea25264841187a9df703d6b;p=old-jaiswallab-svn%2F.git Deleted svn path=/; revision=469 --- diff --git a/image_annotation_db/ia_upload/annotation_data_importer.pl~ b/image_annotation_db/ia_upload/annotation_data_importer.pl~ deleted file mode 100644 index debbbef..0000000 --- a/image_annotation_db/ia_upload/annotation_data_importer.pl~ +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/perl -w - -=head1 NAME - - Image Annotation Data Importer - -=head1 VERSION - - 0.1 - -=head1 DESCRIPTION - - Read the data from the tab de;imited files present in the image_data directory present adjacent to this file - Add more description - -=head1 USAGE - - annotation_data_importer.pl - -=cut - -# general - -use strict; -use English; -use DBI; - -# configurations - -use constant IMAGE_DATA_DIR => "image_data"; - -sub establish_db_connection -{ - return DBI->connect('DBI:mysql:image_annotation;host=floret.cgrb.oregonstate.edu', 'lingutln', 'nikhil_iadb', - { RaiseError => 1 } - ); -} - -sub insert_curator_data(my $dbh, my @image_data_fields) -{ - my($curator_first, $curator_last) = split(/ /, $image_data_fields[6], 2); - my $curator_email = $image_data_fields[7]; - my $curator_affiliation = $image_data_fields[8]; - - $dbh->do('INSERT INTO curator (firstname, lastname, primary_email, alternate_email, affiliation) VALUES(?, ?, ?, ?, ?)', undef, $curator_first, $curator_last , $curator_email ,'', $curator_affiliation); - -} - -sub insert_record_into_database -{ - my $dbh = establish_db_connection; - - my @image_data_fields = split(/\t/); - - insert_curator_data($dbh, @image_data_fields); - - - -} - -sub import_image_data -{ - - print "Opening each image data(*.tsv) file and reading data...\n\n"; - - foreach (glob(IMAGE_DATA_DIR."/*.tsv")) - { - - my $content = do { - local $/ = undef; - open (my $file, "<", $_) or die("could not open $_: $!"); - <$file>; - }; - - chomp; - - my @image_data_records = split(/\n/, $content); - - splice @image_data_records, 0, 1; - - foreach (@image_data_records) - { - insert_record_into_database($_); - } - - close $_ or die("Could not close '$_': $OS_ERROR"); - - } -} - -# --------------------------------------------------------------------------- - # main -# --------------------------------------------------------------------------- - -import_image_data; -exit; - -# --------------------------------------------------------------------------- -# end -# ---------------------------------------------------------------------------