Number of Consecutive Occurences


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Number of Consecutive Occurences
# 1  
Old 10-24-2013
Lightbulb Number of Consecutive Occurences

Smilie
Hi Folks,
I have a requirement to find the number of consecutive occurences based on month. Here is the below sample of my requirement.

I have say four columns

CARUSERNAME BRAND_CODE MONTH YEAR

Below is sample Data
Code:
John|C|JAN|2013
Tim|C|FEB|2013
Tom|C|Mar|2013
Ron|C|Apr|2013
Phil|C|Dec|2013
Linda|C|Mar|2013
Dave|D|Apr|2013
Greg|D|May|2013

Like above I have a dataset containing 50 million records.

The output of my report should be
Code:
Number of ConsecutiveMonths | Brand |
C D
2 | 1 -
3 | - -
4 | - 1

Is there a way it can be programmed in unix?
Smilie

Last edited by vbe; 10-24-2013 at 12:25 PM.. Reason: code tags not icode please
# 2  
Old 10-24-2013
What cant you do or what have you done so far?
# 3  
Old 10-24-2013
Not clear. Explain way more.
# 4  
Old 10-24-2013
I have attached the report sample for better understanding
# 5  
Old 10-25-2013
The report sample that you attached does not provide better understanding. It doesn't contain the same data as your other sample (not even the same fields).

The data in message #1 in this thread seems to be sorted with the key: Increasing alphanumeric order of BRAND_CODE. The other fields do not appear to be sorted. There are no two records with the same CARUSERNAME. There is no indication of what the values in the table mean.

The data in the attachment in message #4 in this thread seems to be sorted with the keys: Increasing alphanumeric order of Brand, and either increasing calendar order of Month or decreasing alphanumeric order of Name. The entries in the output table seem to be arranged by groupings of Brand and Name. You seem to say that March, April, and June are three consecutive months (what happened to May)?

If you can't give us a clear description (in English) describing how the data is to be processed and a clear statement and corresponding example of what output you're trying to produce; we can't help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count and print the number of occurences

I have some files as shown below GLL ALM 654-656 654 656 SEM LYG 655-657 655 657 SEM LYG 655-657 655 657 ALM LEG 656-658 656 658 ALM LEG 656-658 656 658 ALM LEG 656-658 656 658 LEG LEG 658-660 658 660 LEG LEG 658-660 658 660 The value of GLL is... (5 Replies)
Discussion started by: arch
5 Replies

2. Shell Programming and Scripting

Count number of occurences using awk

Hi Guys, I have 2 files like below file1 xx yy file2 b yy b2 xx c1 yy xx yy Now I want an idea which can count occurences of text from file1 and file2 so outbout would be kind of (9 Replies)
Discussion started by: prashant2507198
9 Replies

3. UNIX for Dummies Questions & Answers

Number of word occurences in a file?

Hello world, Can anybody tell me how to count how many times does a word repeat in a file? There have been many threads on this but they all are heavy loads of Scripting for a starter like me. :D So, I sat down today and after some hours of reading man pages, I found a simple one-line... (18 Replies)
Discussion started by: satish51392111
18 Replies

4. Shell Programming and Scripting

to count the number of occurences of a column value

im trying to count the number of occurences of column 2 value(starting from KKK*) of the below file, file.txt using the code cat file.txt | awk ' BEGIN { print "Category Counts"} {FS=","} {NR > 2} { cats = cats + 1} END { for(c in cats) { print c, "=", cats} } ' but its returning as ... (6 Replies)
Discussion started by: michaelrozar17
6 Replies

5. Shell Programming and Scripting

awk counting number of occurences

Hi, I am trying to count the max number of occurences of field1 in my apache log example: 10.0.0.1 field2 field3 10.0.0.2 filed2 field3 10.0.0.1 field2 field3 10.0.0.1 field2 field3 awk result to print out only the most occurence of field1 and number of occurence and field1 is... (3 Replies)
Discussion started by: phamp008
3 Replies

6. UNIX for Dummies Questions & Answers

Count number of occurences of a word

I want to count the number of occurences of say "200" in a file but that file also contains various stuff including dtaes like 2007 or smtg like 200.1 so count i am getting by doing grep -c "word" file is wrong Please help!!!!! (8 Replies)
Discussion started by: shikhakaul
8 Replies

7. Shell Programming and Scripting

counting the number of occurences

say i've got a text file with >10million sequences: ssss ssss tttttt uuuuuu uuuuuu uuuuuu ... I'd like to convert the file so that the output will report the number of occurence right by each sequence: 2 ssss 2 ssss 1 tttttt 3 uuuuuu 3 uuuuuu 3 uuuuuu .... (3 Replies)
Discussion started by: johjoh
3 Replies

8. Shell Programming and Scripting

How to count the number of occurences of this pattern?

Hi all, I have a pattern like this in a file: 123 4 56 789 234 5 67 789 121 3 56 789 222 4 65 789 321 6 90 100 478 8 40 789 243 7 80 789 How can I count the number of occurences of '789' (4th column) in this set...? Thanks for all your help! K (7 Replies)
Discussion started by: kripssmart
7 Replies

9. UNIX for Dummies Questions & Answers

Counting number of occurences

Hi All, I have to count the number of occurences of the character " ; " in a given line. I had used the following awk command to achieve the same echo $KOP.dat|awk '{split($1,my,";"); for(i in my)c++ }END{print c-1}' My file KOP.dat had the following data ... (1 Reply)
Discussion started by: kingofprussia
1 Replies

10. Shell Programming and Scripting

number of occurences of a string

hi, I have a file where i need to count the occurences of a string ex) 'welcome to unix forum'. can anybody help me out (12 Replies)
Discussion started by: siddu_chittari
12 Replies
Login or Register to Ask a Question