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 4016754
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:46:43+00:00 2026-05-20T09:46:43+00:00

I want to write a Java class that will take a CSV file and

  • 0

I want to write a Java class that will take a CSV file and take the min, max, average, etc… of various statistics. Please see below for a sample of this file. For example, I want to get the stats for “Opening login page”, “Logging in as lead user”, etc..

I have started by reading TestName and Time into a Map:

static Map<String, String> data = new TreeMap<String, String>();
...
for (String line : file) {
if (line.contains("Test Name")){
//Get next line, this is the first one.
continue;
}
String TestName = (line.substring(0,line.indexOf(","))).trim();
String Time = (line.substring(line.lastIndexOf(",")+2, line.length())).trim();
//System.out.println(TestName + " " + Time);
data.put(TestName, Time);
}

This works fine. However, I’m not sure of the best way to go about getting all unique values and running the calculation. I don’t need to use a Map, it was what just popped into my head. Does anyone know how to do something like this?

CSV file sample:

Test Name, Thread No, Run No, Time(s)
Opening login page, 0, 0, 1.8869998455047607
Opening login page, 1, 0, 2.246999979019165
Opening login page, 2, 0, 2.1710000038146973
Logging in as regular user, 1, 0, 22.009999990463257
Logging in as regular user, 1, 0, 22.009999990463257
Logging in as regular user, 1, 0, 22.009999990463257
Logging in as lead user, 0, 0, 23.616000175476074
Opening login page, 13, 0, 2.125999927520752
Opening login page, 15, 0, 1.8939998149871826
Logging in as lead user, 3, 0, 20.244999885559082
Logging in as lead user, 2, 0, 23.039999961853027 
  • 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-05-20T09:46:44+00:00Added an answer on May 20, 2026 at 9:46 am

    For parsing csv, refer
    http://www.java-examples.com/parse-csv-file-using-stringtokenizer-example

    You can use Set as u need unique values.
    For stats, use functions of Collections class like Collections.max(hashSetObj).

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

Sidebar

Related Questions

I want to write some JavaScript that will change the onmousedown of a div
I write a Text Editor with Java , and I want to add Undo
How can I read/write serializable object instances to a RandomAccessFile in Java? I want
I want to write a command that specifies the word under the cursor in
I want to write a function in Python that returns different fixed values based
I want to write a function that takes an array of letters as an
I want to write a word addin that does some computations and updates some
Hello I want write my own desktop sharing application in Java. The application should
I want to write a Swing application in Griffon but I am not sure
I want to write a little DBQuery function in perl so I can have

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.