/[virtual-ldap]/bin/csv2yaml-upisi2010.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/csv2yaml-upisi2010.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 96 by dpavlin, Tue Jul 13 13:21:17 2010 UTC revision 97 by dpavlin, Tue Jul 13 14:15:50 2010 UTC
# Line 10  use YAML qw/DumpFile/; Line 10  use YAML qw/DumpFile/;
10  use Text::CSV;  use Text::CSV;
11    
12  my $debug = 0;  my $debug = 0;
13    my $dir = 'yaml/hrEduPersonUniqueNumber_JMBG';
14    
15    mkdir $dir unless -e $dir;
16    
17  my $path = shift @ARGV || die "usage: $0 file.csv\n";  my $path = shift @ARGV || die "usage: $0 file.csv\n";
18    
# Line 22  while ( my $row = $csv->getline( $fh ) ) Line 25  while ( my $row = $csv->getline( $fh ) )
25          my ( $ulica, $grad ) = split(/\s*,\s*/, $row->[8]);          my ( $ulica, $grad ) = split(/\s*,\s*/, $row->[8]);
26    
27          my $info = {          my $info = {
28                    prezime => $row->[0],
29                    ime => $row->[1],
30                  jmbg => $row->[2],                  jmbg => $row->[2],
31                    datum_rodjenja => $row->[3],
32                    email => $row->[4],
33                  adresa_ulica => $ulica,                  adresa_ulica => $ulica,
34                  adresa_grad  => $grad,                  adresa_grad  => $grad,
35                  tel_fixed => $row->[9],                  tel_fixed => $row->[9],
# Line 30  while ( my $row = $csv->getline( $fh ) ) Line 37  while ( my $row = $csv->getline( $fh ) )
37                  spol => substr($row->[2],9,3) < 500 ? 'M' : 'F',                  spol => substr($row->[2],9,3) < 500 ? 'M' : 'F',
38          };          };
39    
40          warn dump($row, $info);          my $uuid = $row->[2];
41          #DumpFile( "yaml/$uuid.yaml", $hash );          DumpFile( "$dir/$uuid.yaml", $info );
42            warn "$uuid\n";
43  }  }
44  $csv->eof or $csv->error_diag();  $csv->eof or $csv->error_diag();
45  close $fh;  close $fh;

Legend:
Removed from v.96  
changed lines
  Added in v.97

  ViewVC Help
Powered by ViewVC 1.1.26