#!/usr/bin/perl use Text::ParseWords; + use Data::Dumper; + use IO::File; #my $file = test.csv; + my $file = $ARGV[0]; my ($output_file) = ($file =~ /(.*)\./); + open(my $fh, '<', $file) or die "Can't read csv file '$file' [$!]\n"; + my $countlines = 0; my $countlines1 = 0; while (my $line = <$fh>) {while (my $line = <$fh>) { chomp $line; my @fields = Text::ParseWords::parse_line(',', 0,$line); + if($countlines >= 0 && @fields[0]==201120) {if ( @fields[1]==1){ $countlines1 = $countlines1 + 1;} $countlines++; } } print "$countlines\n"; print "$countlines1\n"; $yield = ($countlines1 / $countlines)*100 ; print $yield; }
Thank for your reply,it does not have to be the same csv file. Currently , my code able read one week only and print it volume and yield. I need some guides from you all.
In reply to Re^2: how do I manipulate data in csv file
by Anonymous Monk
in thread how do I manipulate data in csv file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |