Counting values in a list 2

Posted on 2013-11-17
Medium Priority
Last Modified: 2013-11-17
I know very little about PERL :(

I have list of millions of rows of data. All data values are separated by a comma

I have to count how many rows contain a specific data value

for example


from that sample list, I have to count how many rows have the value 103 for the second data entry, so for this list the number of rows with 103 in the second data entry would be 3

Could someone help me with a PERL script that I can run as a .pl file and will

1. open the file  (filename:  master.vim )
2. Count through all the rows and record the number of rows with the value at that data point - in the second column
3. write the recorded number of rows to another file (  count103.txt  )
4. close master.vim and count.txt

Thankyou very much in advance
Question by:Europa MacDonald
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 14

Accepted Solution

jb1dev earned 2000 total points
ID: 39654944

open FILE, "<master.vim";
my $count = 0;

while(<FILE>) {
    my @columns = split(',');
    if($columns[1] eq '103') {
close FILE;

open OUT, ">count.txt";
print OUT "$count\n";
close OUT;

Open in new window


Author Closing Comment

by:Europa MacDonald
ID: 39654961
great thanks

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Six Sigma Control Plans

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question