[freeside-commits] freeside/bin svc_acct_pop.import,NONE,1.1
Jeff Finucane,420,,
jeff at wavetail.420.am
Fri Mar 9 09:11:37 PST 2007
- Previous message: [freeside-commits]
freeside/install/5.005/DBIx-DBSchema-0.23-5.005kludge/t
load-mysql.t, 1.1, NONE load-pg.t, 1.1, NONE load.t, 1.1, NONE
- Next message: [freeside-commits] freeside/FS/FS Record.pm, 1.136,
1.137 svc_broadband.pm, 1.11, 1.12
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/bin
In directory wavetail:/tmp/cvs-serv25264
Added Files:
svc_acct_pop.import
Log Message:
pop import tool
--- NEW FILE: svc_acct_pop.import ---
#!/usr/bin/perl
use strict;
use Text::CSV_XS;
use FS::UID qw(adminsuidsetup);
use FS::svc_acct_pop;
my @fields = qw( ac loc state city exch );
my $fixup = sub {
my $hash = shift;
$hash->{ac} =~ /^\s*(\d{3})\s*$/;
$hash->{ac} = $1;
$hash->{loc} =~ /^\s*(\d{3})(\d{4})\s*$/;
$hash->{exch} = $1;
$hash->{loc} = $2;
$hash->{state} =~ /^\s*(\S{0,2})\s*$/;
$hash->{state} = $1;
$hash->{city} =~ /^\s*(.*?)\s*$/;
$hash->{city} = $1;
};
my $user = shift or usage();
adminsuidsetup $user;
my $file = shift or usage();
my $csv = new Text::CSV_XS;
open(FH, $file) or die "cannot open $file: $!";
sub usage {
die "Usage:\n\n svc_acct_pop.import user popfile.csv\n\n";
}
###
my $line;
while ( defined($line=<FH>) ) {
chomp $line;
$line &= "\177" x length($line); # i hope this isn't really necessary
$csv->parse($line)
or die "cannot parse: " . $csv->error_input();
my @values = $csv->fields();
my %hash;
foreach my $field (@fields) {
$hash{$field} = shift @values;
}
&{$fixup}(\%hash);
my $svc_acct_pop = new FS::svc_acct_pop { %hash };
#my $error = $svc_acct_pop->check;
my $error = $svc_acct_pop->insert;
die $error if $error;
}
- Previous message: [freeside-commits]
freeside/install/5.005/DBIx-DBSchema-0.23-5.005kludge/t
load-mysql.t, 1.1, NONE load-pg.t, 1.1, NONE load.t, 1.1, NONE
- Next message: [freeside-commits] freeside/FS/FS Record.pm, 1.136,
1.137 svc_broadband.pm, 1.11, 1.12
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list