bittis has asked for the wisdom of the Perl Monks concerning the following question:
This does not seem to have any effect and returns broken records. The following is an example of what i did:$csv = Text::CSV_XS->new({binary => 1});
I am not sure what i am doing wrong but it probably has to do with While <INFILE>, I would appreciate any help i could get$csv = Text::CSV_XS->new({binary => 1}); while (<INFILE>) { #while ($csv->parse($_)) if (/"X"/) { #The trash data has these 3 characters in it print "THERE IS TRASH IN THE FILE:: $_\n"; } elsif ($first_line==1){ $first_line=0; } else { #Now to deal with the data I want to keep if($csv->parse($_)) { #checks to see if data exists in + $_ and +parses it if it does my @fields=$csv->fields; # puts the values from each field in + an +array my $elements=@fields; #gets the number of elements in the +arra +y my $x=0; # for ($x=0;$x<$elements;$x++) { # print "$fields[$x]\t"; print "\n"; if ($fields[$x]=~ m/\d+/i){ print "LOGID: $fields[$x++]\n"; print "LOGDATE: $fields[$x++]\n"; print "EMPID: $fields[$x++]\n"; print "CATEGORY: $fields[$x++]\n"; print "SUBCAT: $fields[$x++]\n"; print "OS: $fields[$x++]\n"; print "DESCR: $fields[$x++]\n"; print "ACTION: $fields[$x++]\n"; print "ASSIGNTO: $fields[$x++]\n"; print "STATUS: $fields[$x++]\n"; } else { print "\problematic field found "; $counterp++; print "LOGID: $fields[$x++]\n"; # $asdf=<>; } # } $counter++; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Text::CSV_XS and "binary" mode
by Tux (Canon) on Jan 26, 2009 at 07:49 UTC | |
by bittis (Sexton) on Jan 26, 2009 at 08:14 UTC | |
by Tux (Canon) on Jan 26, 2009 at 10:01 UTC | |
|
Re: Text::CSV_XS and "binary" mode
by moritz (Cardinal) on Jan 26, 2009 at 07:49 UTC | |
by bittis (Sexton) on Jan 26, 2009 at 08:38 UTC | |
by moritz (Cardinal) on Jan 26, 2009 at 08:43 UTC | |
by bittis (Sexton) on Jan 26, 2009 at 08:53 UTC | |
by moritz (Cardinal) on Jan 26, 2009 at 09:10 UTC | |
by Marshall (Canon) on Jan 26, 2009 at 09:06 UTC | |
by bittis (Sexton) on Jan 26, 2009 at 09:29 UTC | |
by Tux (Canon) on Jan 26, 2009 at 11:11 UTC | |
| |
by Marshall (Canon) on Jan 26, 2009 at 11:35 UTC | |
|