Counting individual occurrences in a file

Find quick help here to get you started with Hollywood
Post Reply
User avatar
JurassicC
Posts: 35
Joined: Fri May 25, 2012 9:48 pm

Counting individual occurrences in a file

Post by JurassicC » Wed Jul 03, 2019 12:07 pm

Example Output file (output.txt)

4-0-4
4-0-4
4-0-4
4-0-5
4-1-18
4-1-18
4-1-18
4-1-18
4-1-18
.
.
.
.







What I'm doing

I'm opening a file which has been created in another executable, output.txt, and putting each line in array words[] to store the words.
I'm also opening another array count[] to count all the words in the file

now this is where I am stuck.

ultimately I want to get to the point where I can output a tally of all occurrences.

word qty
4-0-4 3
4-0-5 1
4-1-18 5

etc etc

any pointer would be great :)
AmigaOne X1000 - RadeonHD 7870, 4GB RAM - AmigaOS 4.1ß
AmigaOne X5000 - Radeon R7 250, 2GB RAM - AmigaOS 4.1ß

SamuraiCrow
Posts: 222
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

Re: Counting individual occurrences in a file

Post by SamuraiCrow » Wed Jul 03, 2019 1:53 pm

To save lookup time use the words as the keys of the count table and ditch the arrays.

Post Reply