Moved project directories and files to an empty local repo
This commit is contained in:
71
InternetArchive/show_metadata
Executable file
71
InternetArchive/show_metadata
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env perl
|
||||
#===============================================================================
|
||||
#
|
||||
# FILE: show_metadata
|
||||
#
|
||||
# USAGE: ./show_metadata
|
||||
#
|
||||
# DESCRIPTION: Script to display a file of metadata in a readable format
|
||||
#
|
||||
# OPTIONS: ---
|
||||
# REQUIREMENTS: ---
|
||||
# BUGS: ---
|
||||
# NOTES: ---
|
||||
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
|
||||
# VERSION: 0.0.2
|
||||
# CREATED: 2014-06-09 16:17:11
|
||||
# REVISION: 2014-06-15 12:26:58
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
use 5.010;
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
|
||||
use List::Util qw{max};
|
||||
use Text::CSV_XS;
|
||||
|
||||
#
|
||||
# Version number (manually incremented)
|
||||
#
|
||||
our $VERSION = '0.0.2';
|
||||
|
||||
#
|
||||
# Script name
|
||||
#
|
||||
( my $PROG = $0 ) =~ s|.*/||mx;
|
||||
|
||||
#
|
||||
# Enable Unicode mode
|
||||
#
|
||||
binmode STDOUT, ":encoding(UTF-8)";
|
||||
binmode STDERR, ":encoding(UTF-8)";
|
||||
|
||||
my $mdata = shift;
|
||||
die "Usage: $PROG filename\n" unless $mdata;
|
||||
|
||||
die "File $mdata does not exist\n" unless -e $mdata;
|
||||
|
||||
my $csv = Text::CSV_XS->new({ binary => 1 });
|
||||
|
||||
open( my $fh, "<:encoding(utf8)", $mdata )
|
||||
or die "Unable to open $mdata: $!\n";
|
||||
|
||||
my @cols = @{ $csv->getline($fh) };
|
||||
my $max = max map { length($_) } @cols;
|
||||
my $row = {};
|
||||
$csv->bind_columns( \@{$row}{@cols} );
|
||||
while ( $csv->getline($fh) ) {
|
||||
foreach my $key (@cols) {
|
||||
printf "%*s: %s\n", $max, $key, $row->{$key};
|
||||
}
|
||||
print '-' x 80, "\n";
|
||||
}
|
||||
|
||||
close($fh);
|
||||
|
||||
exit;
|
||||
|
||||
# vim: syntax=perl:ts=8:sw=4:et:ai:tw=78:fo=tcrqn21:fdm=marker
|
||||
|
Reference in New Issue
Block a user