+++ /dev/null
-#!/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
-# ---------------------------------------------------------------------------