IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5190


Ignore:
Timestamp:
Sep 29, 2005, 12:12:15 PM (21 years ago)
Author:
jhoblitt
Message:

output result of find_new() as CSV

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-MetaDB/scripts/mdb-find-new

    r5187 r5190  
    33# Copyright (C) 2005  Joshua Hoblitt
    44#
    5 # $Id: mdb-find-new,v 1.1 2005-09-29 21:28:45 jhoblitt Exp $
     5# $Id: mdb-find-new,v 1.2 2005-09-29 22:12:15 jhoblitt Exp $
    66
    77use strict;
     
    1212
    1313use PS::IPP::MetaDB;
     14use Text::CSV;
    1415
    1516use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    3435pod2usage( -msg => "Required options: --dsn --user", -exitval => 2 )
    3536    unless defined $dsn and defined $dbuser;
    36 #pod2usage( -msg => "Required options: --exp_id --class_id", -exitval => 2)
    37 #    unless defined $exp_id and defined $class_id;
    3837
    3938PS::IPP::MetaDB->init(
     
    4342);
    4443
     44my @rows;
    4545if (defined $exp_id) {
    46     PS::IPP::MetaDB->find_new(
     46    @rows = PS::IPP::MetaDB->find_new(
    4747        exp_id      => $exp_id,
    4848        class_id    => $class_id,
    4949    );
    5050} else {
    51     PS::IPP::MetaDB->find_new();
     51    @rows = PS::IPP::MetaDB->find_new();
     52}
     53
     54my @fields = qw( exp_id class_id camera class url );
     55my $csv = Text::CSV->new();
     56
     57print "# ", join(", ", @fields), "\n";
     58foreach my $hashref (@rows) {
     59    $csv->combine(@$hashref{@fields});
     60    print $csv->string, "\n";
    5261}
    5362
Note: See TracChangeset for help on using the changeset viewer.