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

  • Home
  • SEARCH
  • 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 4564542
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:30:58+00:00 2026-05-21T18:30:58+00:00

I am reading two csv files containg a set of attributes File 1 attributes

  • 0

I am reading two csv files containg a set of attributes

File 1 attributes = name, class, rollno,   
File 2 attributes = rollno, city,town

I need to match the two files and for every matching rollno I have to append the File 2 attributes into File1 and create a csv file in the format
rollno, name, class, city, town

So far I have succeeded in reading the File1 and file2 values into a List of linked hashmaps of the type.

List<Map<Object, Object>> _students = new ArrayList<Map<Object, Object>>();

I am not able to figure out the steps to move forward.

How do I search through the list map of first file for the roll no contained in the second listmap and append it to the firstlistmap?

and then print it to a csv file in the order specified ( I am able to iterate and print all the values in the order they were inserted in the map)

  • 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-21T18:30:59+00:00Added an answer on May 21, 2026 at 6:30 pm

    I would approach this problem by reading the first file and store the values in a hashmap. and then append to that hashmap
    The key would be the role number and the value would be a list of the the other values.

    Map<String, List<String>> map = new HashMap<String, List<String>>()
    
    Pseudocode:
    
    for (List<String> line : file1.lines) {
     List curLine = new LinkedList();
     curLine.add(line.get(0));
     curLine.add(line.get(1));
    
     map.put(line.get(2),curLine)
    }
    
    for (List<String> line : file2.lines) {
     String key = line.get(0);
     String list = map.get(key);
     if (list != null)
     {
      list.add(line.get(1));
      list.add(line.get(2));
     }
    
     map.put(key,list); // probably not necessary as you change the reference that is already in the map, but I'm not sure
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two implementation of reading csv files, the csv files in
I have two excel files. First excel file contains the Person Name and Total
I've got a CSV file with two sets of data in it [its pulled
I am reading in a csv file in Java and, depending on the format
I am currently reading a CSV file. I have to extract the dates from
I have a csv file as this: 1#one#two#three#four; 2#apple#tower#flower#robot; I read this file with
In a project I'm working on, I need to read from a CSV file,
Possible Duplicate: Reading csv file I have a comma delimited file: Some Text, More
Below are two ways of reading in the commandline parameters. The first is the
I have two threads, one updating an int and one reading it. This is

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.