-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport
67 lines (45 loc) · 1.42 KB
/
import
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env perl
use warnings;
use strict;
use Getopt::Long;
use Pod::Usage;
use FindBin;
use lib "lib";
use DataStore qw(saveTsv);
my %opt = (
datadir => "$FindBin::Bin/data"
);
GetOptions(\%opt,
"help",
"file=s",
"datadir=s"
)
or pod2usage(2);
pod2usage(-exitval => 0, -verbose => 2) if $opt{help};
pod2usage("File is a required argument!") if !$opt{file};
die "Couldn't read data directory!" if !-r $opt{datadir};
die "Couldn't read import file!" if !-r $opt{file};
DataStore::saveTsv($opt{datadir}, $opt{file});
__END__
=head1 NAME
import: Import a file into the comScore Programming Challenge datastore
=head1 SYNOPSIS
import --file <path> [--datadir <directory>] [--help]
=head1 OPTIONS
=over
=item file <path>
Required. Path to the file that should be imported
=item datadir <directory>
Optional. Path to the directory where the datastore is located
=item help
Optional. This message
=back
=head1 DESCRIPTION
Imports a file into the comScore Programming Challenge datastore. Merges it
with the existing datastore by overwriting existing entries, if an existing
entry is already present. An entry is deemed to be present if the incoming
STB, TITLE, and DATE are the same as an existing entry. Also performs
immediate cleanup - in the case where an incoming entry overwrites an existing
entry, this script determines if any old/orphan data can be deleted from the
datastore as a result of the overwrite.
=cut