Created
February 4, 2011 14:49
-
-
Save polettix/811186 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Text::CSV; | |
my @columns = ''; | |
my $region = ''; | |
my $valore = ''; | |
my @lac1 = ''; | |
my @lac2 = ''; | |
my @lac3 = ''; | |
my @lac4 = ''; | |
my @lac5 = ''; | |
my @lac6 = ''; | |
my $i = ''; | |
my $cellid = ''; | |
my $outputfile = "example2.ldif"; | |
my $csv = Text::CSV->new(); | |
my $filename = $ARGV[0] or die "Must specify filename to parse.\n"; | |
open my $INFO, '>', $outputfile or die "open(): $!"; | |
open my $CSV, '<', $filename or die "open(): $!"; | |
while (<$CSV>) { | |
last unless /\S/; | |
if ($csv->parse($_)) { | |
@columns = $csv->fields(); | |
#print "@columns\n"; | |
$region = substr($columns[0],0,1); | |
$cellid = substr($columns[0],1,5); | |
if ($region == "1") { | |
push(@lac1,$cellid); | |
} elsif ($region == "2") { | |
push(@lac2,$cellid); | |
} elsif ($region == "3") { | |
push(@lac3,$cellid); | |
} elsif ($region == "4") { | |
push(@lac4,$cellid); | |
} elsif ($region == "5") { | |
push(@lac5,$cellid); | |
} elsif ($region == "6") { | |
push(@lac6,$cellid); | |
} | |
} else { | |
my $err = $csv->error_input; | |
print "Failed to parse line: $err"; | |
} | |
} | |
for $i(0..$#lac1) { | |
if ($lac1[$i]) { | |
print $INFO "value:$lac1[$i]\n"; | |
} | |
} | |
for $i(0..$#lac2) { | |
if ($lac2[$i]) { | |
print $INFO "value:$lac2[$i]\n"; | |
} | |
} | |
for $i(0..$#lac3) { | |
if ($lac3[$i]) { | |
print $INFO "value:$lac3[$i]\n"; | |
} | |
} | |
for $i(0..$#lac4) { | |
if ($lac4[$i]) { | |
print $INFO "value:$lac4[$i]\n"; | |
} | |
} | |
for $i(0..$#lac5) { | |
if ($lac5[$i]) { | |
print $INFO "value:$lac5[$i]\n"; | |
} | |
} | |
for $i(0..$#lac6) { | |
if ($lac6[$i]) { | |
print $INFO "value:$lac6[$i]\n"; | |
} | |
} | |
close $CSV; | |
close $INFO; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment