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 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

So I'm reading a CSV file with two columns, and then taking the product
I am reading two files and I want for each line in file one
I have the following two implementation of reading csv files, the csv files in
I wish to: Reading in two files Split the files into individual strings Compare
I've got a CSV file with two sets of data in it [its pulled
When reading two dates from a binary file I'm seeing the error below: The
Can anyone give me the working example of reading two files simultaneously through threads?
I am working on a program that will eventually compare two .csv files and
All, I'm reading a csv file and adding the data to a MySQL DB
I've been reading two articles (1) (2) on javaworld.com about how all class fields

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.