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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:02:18+00:00 2026-06-09T10:02:18+00:00

I found this problem so interesting. I am using an awk 2D array that

  • 0

I found this problem so interesting. I am using an awk 2D array that has a key,value,count of the same. and that is being printed to a file. This file is in the below format

A100|B100|3
A100|C100|2
A100|B100|5

Now I have a file like this .. My motive is to convert this file into a hash map so that the final output from the hash map is.

A100|B100|8
A100|C100|2

Just an aggregation

The challenge is, this one has 3 dimensions and not two. I did have an another file in the below format which is

D100|4
H100|5
D100|6

I easily aggregated the above as it is only 2D and I used the below code to do that

String[] fields= strLine.trim().split("\\|");
if(hashmap.containsKey(fields[0]))
{
//Update the value of the key here
hashmap.put(fields[0],hashmap.get(fields[0]) + Integer.parseInt(fields[1]));
}
else
{
//Inserting the key to the map
hashmap.put(fields[0],Integer.parseInt(fields[1]));
}

So this was quite simple for implementation.

But when it comes to 3D I have to have an another check inside.. My idea for this is to maintain a [B100,5(beanObject[5])]

  Map<String,beanClassObject> hashmap=new Map<String,beanClassObject>();

secongField hash map which has been used in the code that has a mapping relation between the created ben Object subscript and the key as the second field “For instance it is “

This bean class would have the getter and setter method for the 2nd and 3rd fields of the file. I hope I am clear with this point. So the implementation of this would be

if(hashmap.containsKey(fields[0]))
{
   **//Have to check whether the the particular key value pair already exists ... I dint find any method for this ... Just a normal iteration is there .. Could you ppl guide me regarding this**

    //Update the value of the key here
     secondFieldHashMap.get(fields[1]).COunt= secondFieldHashMap.get(fields[1]).getCOunt+ Integer.parseInt(fields[2]));
   }
   else
    {
     //Inserting the key to the map
     hashmap.put(fields[0],Integer.parseInt(fields[1]));
     secondFieldHashMap.get(fields[1]).COunt=  Integer.parseInt(fields[2]));
    }
else
{

 // This meands there is no key field
 // Hence insert the key field and also update the count of seconfFieldHashMap as done previously.
 }

COuld you ppl please throw some ideas regarding this. Thank you

  • 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-09T10:02:21+00:00Added an answer on June 9, 2026 at 10:02 am

    Consider using a Table available in the Google Guava libraries.

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

Sidebar

Related Questions

I am using a NamedParameterJdbcTemplate, but found that this problem is in the underlying
Searched a lot about this problem but never found a answer, that solved it.
I found this problem, which I thought would be interesting to solve but couldn't
I found this problem in a book. Problem: What is the output of the
Possible Duplicate: Can main function call itself in C++? I found this problem very
Ok, so I'm quite new to jQuery, but found this bizzare problem just now,
i have this problem: ms-access could not delete and i found a potential solution
Already found this page with some helpful hints. Problem is I need to debug
Although I have found some solutions to this problem, none of them refer to
This problem pops around the network for years, I've found no good solution yet.

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.