Mercurial > repos > marpiech > norwich_tools
comparison tools/rdock/bin/sdfield @ 0:bc03dbb6eb37 draft
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
author | marpiech |
---|---|
date | Mon, 29 Aug 2016 03:38:13 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bc03dbb6eb37 |
---|---|
1 #!/usr/bin/perl | |
2 # add extra fields to SD records | |
3 use lib "$ENV{'RBT_ROOT'}/lib"; | |
4 use SDRecord; | |
5 | |
6 printHelpAndExit() if (scalar(@ARGV) == 0); | |
7 #Parse command line arguments | |
8 my @files; | |
9 my $arg = shift @ARGV; | |
10 printHelpAndExit() if ($arg eq '-h'); | |
11 #read records | |
12 my $sdRec = new SDRecord; | |
13 my $nRec=0; | |
14 # if not -h, then must be the FieldName | |
15 my $FieldName = $arg; | |
16 my $FieldVal = shift @ARGV; # and this must be the filed value | |
17 # rest are the filenames | |
18 while ($sdRec->readRec('DATA'=>1,'LINES'=>1)) { | |
19 $sdRec->addData('_REC' => ++$nRec);#add record# as temp data field | |
20 $sdRec->addData('_FILE' => $ARGV);#add filename as temp data field | |
21 $sdRec->addDataAndLines($FieldName => $FieldVal); | |
22 $sdRec->writeRec();#write record | |
23 } | |
24 | |
25 sub printHelpAndExit { | |
26 print "\nAdding fields to SD files\n"; | |
27 print "Usage:\n"; | |
28 print "\tsdfield <Fieldname> <value> <infile[s]>\n"; | |
29 print "\t-h\tthis help\n"; | |
30 print "\t\n"; | |
31 } |