Given a txt log file, which is in the form:
USER_A timestamp1 otherstuff
USER_B timestamp2 otherstuff
USER_C timestamp3 otherstuff
USER_A timestamp4 otherstuff
USER_A timestamp5 otherstuff
USER_C timestamp6 otherstuff
USER_B timestamp7 otherstuff
How would you count the number of different unique users in erlang? I was thinking about reading the file line by line and using proplists module. Each user will be a key, with a value that will be the number of occurrences. Once the file is read, I call:
length(proplists:get_keys(List)).
Is this the correct way to achieve my result?
I would also use the sets module for this since it is both fast and as a set contains no duplicates.
The following code should do the job:
Edit: I deleted the one-liner since it didn’t add any value