1
2
3
4
UID;type;No;ACAD;PRÜFEN;EXTERN;MIGRATION;DM;LISP;VBA;UTM;Bemerkungen;Björn prfen;Stellberg;EBL_ERFASSUNG;PRIO;Name;Command;SmallImage;LargeImage;BJ_TBLOGOUT
ID_02;Any;;;;;x;;;x;;;;;;;Zoom auf Straße und Hausnummer;"^C^C(C:BJ_TBLOGOUT);-vbarun BJ__POSFIND STR_HSNR EBL_KANAL";ICBJ0162;ICBJ0162;
ID_03;Any;;;;;x;;;x;;;;;;;Zoom auf Gemarkung/Flur/Flurstück;"^C^C(C:BJ_TBLOGOUT);-vbarun BJ__POSFIND GEM_F_FL ALK";ICBJ0161;ICBJ0161;
ID_04;Any;;;;;x;x;;x;;;;;;;Bildaufbau - Sielkataster/ALK;"^C^C(C:BJ_TBLOGOUT);-vbarun BJ__TBWSC_1 80 ""NULL"" ""EBL_KANAL"" ""LAYER_ALK_AW""";ICBJ0331;ICBJ0331;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/usr/bin/perl use strict; use warnings; use Text::CSV; my $file='MenuGroup_bereinigt.csv'; my $s_delimiter = ";"; open(my $fh, '<', $file) or die("ERROR open $file ($!)\n"); my $csv = Text::CSV->new({sep_char => "$s_delimiter"}); #my $csv = Text::CSV->new (); # first line my $key_names=$csv->getline( $fh ); # Array of hashes my @data; # read File while( my $row = $csv->getline( $fh ) ) { my $value={}; $value->{$key_names->[$_]}=$row->[$_] for(0..$#$key_names); push(@data,$value); } # Formated Output use Data::Dumper; print Dumper(\@data);
QuoteC:\Perl-Tools\mnu_auslesen>perl csv2perl.pl
$VAR1 = [];
C:\Perl-Tools\mnu_auslesen>pause
Drücken Sie eine beliebige Taste . . .
Quotebinary ... darunter hatte ich mir etwas anderes vorgestellt !
Quote$VAR1 = \{
'UTM' => '',
'VBA' => '',
"Bj\x{f6}rn pr\x{81}fen" => '',
'BJ_TBLOGOUT' => '',
'PRIO' => '',
'EXTERN' => '',
'DM' => '',
'Stellberg' => '',
'SmallImage' => 'RCDATA_16_ZOOPRE',
'No' => '',
'Command' => '^C^C(BJ-LISPTEST "C:BJ-LAYOUT_A
BJ-LAYOUT_IN" "Y" @())',
'UID' => 'MM_2316',
=> 'x',
'MIGRA'LISP' TION' => '',
'type' => 'Any',
'Name' => 'Zoom im Modelbereich (EW)',
'EBL_ERFASSUNG' => '',
'ACAD' => '',
'Bemerkungen' => '',
"PR\x{dc}FEN" => '',
'LargeImage' => 'RCDATA_16_ZOOPRE'
};
QuoteUse of uninitialized value $_{"LISP"} in concatenation (.) or string at csv2perl
.pl line 30, <$fh> line 574.[/code]
QuoteC:\Perl-Tools\mnu_auslesen>perl csv2perl.pl
syntax error at csv2perl.pl line 29, near "$Data::Dumper::Useqq("
Execution of csv2perl.pl aborted due to compilation errors.
1 2 3 4 5 6 7 8 9 10
# read File while( my $row = $csv->getline( $fh ) ) { my $value={}; $value->{$key_names->[$_]}=$row->[$_] for(0..$#$key_names); push(@data,$value); } $Data::Dumper::Useqq(1); print Dumper(\@data);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/usr/bin/perl use strict; use warnings; use Text::CSV; use Data::Dumper; my $file='MenuGroup_bereinigt.csv'; my $s_delimiter = ";"; open(my $fh, '<', $file) or die("ERROR open $file ($!)\n"); my $csv = Text::CSV->new({binary => 1, sep_char => $s_delimiter}); #my $csv = Text::CSV->new (); # first line my $key_names=$csv->getline( $fh ); # Array of hashes my @data; # read File while( my $row = $csv->getline( $fh ) ) { my $value={}; $value->{$key_names->[$_]}=$row->[$_] for(0..$#$key_names); push(@data,$value); } $Data::Dumper::Useqq(1); print Dumper(\@data);
$Data::Dumper::Useqq = 1;
QuoteC:\Perl-Tools\mnu_auslesen>perl csv2perl.pl
$VAR1 = [
{
"LISP" => "",
"Name" => "Zoom auf Stra\x{df}e und Hausnummer",
"DM" => "",
"PR\x{dc}FEN" => "",
"EXTERN" => "",
"type" => "Any",
"Stellberg" => "",
"UTM" => "",
"Bj\x{f6}rn pr\x{81}fen" => "",
"UID" => "ID_02",
"LargeImage" => "ICBJ0162",
"ACAD" => "",
"SmallImage" => "ICBJ0162",
"Bemerkungen" => "",
"BJ_TBLOGOUT" => "",
"Command" => "^C^C(C:BJ_TBLOGOUT);-vbarun BJ__POSFIND STR_HSNR EBL_K
ANAL",
"PRIO" => "",
"No" => "",
"EBL_ERFASSUNG" => "",
"MIGRATION" => "x",
"VBA" => "x"
},
{
"LargeImage" => "ICBJ0161",
"ACAD" => "",
"UID" => "ID_03",
"SmallImage" => "ICBJ0161",
"UTM" => "",
"Bj\x{f6}rn pr\x{81}fen" => "",
"PRIO" => "",
"Command" => "^C^C(C:BJ_TBLOGOUT);-vbarun BJ__POSFIND GEM_F_FL ALK",
"No" => "",
"Bemerkungen" => "",
"BJ_TBLOGOUT" => "",
"MIGRATION" => "x",
"EBL_ERFASSUNG" => "",
"VBA" => "x",
"LISP" => "",
"PR\x{dc}FEN" => "",
"DM" => "",
"Name" => "Zoom auf Gemarkung/Flur/Flurst\x{fc}ck",
"EXTERN" => "",
"type" => "Any",
"Stellberg" => ""
},
{
"Command" => "^C^C(C:BJ_TBLOGOUT);-vbarun BJ__TBWSC_1 80 \"NULL\" \"
EBL_KANAL\" \"LAYER_ALK_AW\"",
"No" => "",
"PRIO" => "",
"BJ_TBLOGOUT" => "",
"Bemerkungen" => "",
"SmallImage" => "ICBJ0331",
"ACAD" => "",
"LargeImage" => "ICBJ0331",
"UID" => "ID_04",
"Bj\x{f6}rn pr\x{81}fen" => "",
"UTM" => "",
"VBA" => "x",
"MIGRATION" => "x",
"EBL_ERFASSUNG" => "",
"PR\x{dc}FEN" => "",
"DM" => "x",
"Name" => "Bildaufbau - Sielkataster/ALK",
"LISP" => "",
"Stellberg" => "",
"type" => "Any",
"EXTERN" => ""
}
];
Use of uninitialized value $_{"LISP"} in concatenation (.) or string at csv2perl
.pl line 33, <$fh> line 4.
2015-08-31T14:14:12 jan99
say $_->{'LISP'} for @data;
2015-08-31T13:21:13 jan99
QuoteHASH(0x1c340ec)
HASH(0x1c35964)
QuoteUse of uninitialized value $_{'Name'} in concatenation (.) or string at csv.pl l
ine 31, <$fh> line 3.
1 2 3 4 5 6
my $hashref = { 'Name' => 'Hase', 'Wissen' => 'nix', }; print $hashref->{Name}, "\n";