Counting values in a list 2

Posted on 2013-11-17
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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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, step by step, how to integrate R code into a R Sweave document
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

724 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