/[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

Annotation of /bin/csv2yaml-upisi2010.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 97 - (hide annotations)
Tue Jul 13 14:15:50 2010 UTC (13 years, 10 months ago) by dpavlin
File MIME type: text/plain
File size: 1014 byte(s)
create yaml dump files

1 dpavlin 96 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     # 2010-07-13 Dobrica Pavlinusic <dpavlin@rot13.org>
7    
8     use Data::Dump qw/dump/;
9     use YAML qw/DumpFile/;
10     use Text::CSV;
11    
12     my $debug = 0;
13 dpavlin 97 my $dir = 'yaml/hrEduPersonUniqueNumber_JMBG';
14 dpavlin 96
15 dpavlin 97 mkdir $dir unless -e $dir;
16    
17 dpavlin 96 my $path = shift @ARGV || die "usage: $0 file.csv\n";
18    
19     my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
20     or die "Cannot use CSV: ".Text::CSV->error_diag ();
21    
22     open my $fh, "<:encoding(utf8)", $path or die "$path: $!";
23     while ( my $row = $csv->getline( $fh ) ) {
24    
25     my ( $ulica, $grad ) = split(/\s*,\s*/, $row->[8]);
26    
27     my $info = {
28 dpavlin 97 prezime => $row->[0],
29     ime => $row->[1],
30 dpavlin 96 jmbg => $row->[2],
31 dpavlin 97 datum_rodjenja => $row->[3],
32     email => $row->[4],
33 dpavlin 96 adresa_ulica => $ulica,
34     adresa_grad => $grad,
35     tel_fixed => $row->[9],
36     tel_mobile => $row->[10],
37     spol => substr($row->[2],9,3) < 500 ? 'M' : 'F',
38     };
39    
40 dpavlin 97 my $uuid = $row->[2];
41     DumpFile( "$dir/$uuid.yaml", $info );
42     warn "$uuid\n";
43 dpavlin 96 }
44     $csv->eof or $csv->error_diag();
45     close $fh;
46    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26