/[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 96 - (hide annotations)
Tue Jul 13 13:21:17 2010 UTC (13 years, 9 months ago) by dpavlin
File MIME type: text/plain
File size: 828 byte(s)
parse new csv files with 1st year students

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    
14     my $path = shift @ARGV || die "usage: $0 file.csv\n";
15    
16     my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
17     or die "Cannot use CSV: ".Text::CSV->error_diag ();
18    
19     open my $fh, "<:encoding(utf8)", $path or die "$path: $!";
20     while ( my $row = $csv->getline( $fh ) ) {
21    
22     my ( $ulica, $grad ) = split(/\s*,\s*/, $row->[8]);
23    
24     my $info = {
25     jmbg => $row->[2],
26     adresa_ulica => $ulica,
27     adresa_grad => $grad,
28     tel_fixed => $row->[9],
29     tel_mobile => $row->[10],
30     spol => substr($row->[2],9,3) < 500 ? 'M' : 'F',
31     };
32    
33     warn dump($row, $info);
34     #DumpFile( "yaml/$uuid.yaml", $hash );
35     }
36     $csv->eof or $csv->error_diag();
37     close $fh;
38    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26