Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8111349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:04:58+00:00 2026-06-06T02:04:58+00:00

Given a txt log file, which is in the form: USER_A timestamp1 otherstuff USER_B

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:04:59+00:00Added an answer on June 6, 2026 at 2:04 am

    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:

    {ok,Bin} = file:read_file("test"),
    List = binary_to_list(Bin),
    Usernames = [hd(string:tokens(X," ")) || X <- string:tokens(List,[$\n])],
    sets:size(sets:from_list(Usernames)).
    

    Edit: I deleted the one-liner since it didn’t add any value

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given file names like these: /the/path/foo.txt bar.txt I hope to get: foo bar Why
It's a well-known task, simple to describe: Given a text file foo.txt, and a
I have 500 mb log file in server ( .txt file) . My requirement
I want to read a log file(txt file) and view this in txt file
I am having a xml file.this having the path for my log file(txt).This xml
Given a folder structure: parentFolder - ChildFolder1 - somefiletolookfor.txt - (other files and folder)
Given a group of files with the following naming convention: datetime_restofname.txt an example of
I´m executing the following command grep bruno < bash.txt which gives me the right
I have a program which write logging as Text File. namespace logging { using
I'm writing a java application. Currently this produces a file called trace.txt in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.