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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:45:02+00:00 2026-06-04T22:45:02+00:00

I have a file that looks like this: 1st ­ ­ ­ ­­­ 2nd

  • 0

I have a file that looks like this:

    1st ­ ­ ­   ­­­ 2nd ­ ­ ­   ­­­ nth
    e1­ ­ ­ ­   ­­­ ­­v1 ­ ­ ­   ­­­ 1
    e1 ­ ­ ­   ­­­ v3 ­ ­ ­   ­­­ 2
    e1 ­ ­ ­   ­­­ v4 ­ ­ ­   ­­­ 4
    e1 ­ ­ ­   ­­­ v5 ­ ­ ­   ­­­ 7
    e2 ­ ­ ­   ­­­ v1 ­ ­ ­   ­­­ 1
    . ­ ­ ­   ­ ­ ­. ­ ­ ­  ­ ­ ­­­ .
    . ­ ­ ­   ­ ­ ­. ­ ­ ­   ­­­  .
    . ­ ­ ­   ­ ­ ­.      ­  .

I want the first column to be the name of the arraylist (e1, or e2, or e3), I want the second column to have it’s value (an int), inside the nth index.

How would I go about doing that?

Id you’d like further clarification on what I mean, please don’t be afraid to leave a pm.

p.s. This is part of a bigger project, but I’m kind of stuck at the format of the data.

I’m assuming i’ll have to look for an arraylist with the the name (first column) and if i find it, then add the value (2nd column) at the nth value (3rd column), and if I don’t find it, I make an arrayList, and THEN do the aforementioned.

Update

So I managed to get the program almost working — I couldn’t use the original structure of ArrayLists because all variables have to be declared during compilation — can’t be declared after.
I decided to use a hashmap, with the key has the 1st value, and an arraylist of the 2nd values in the nth position:

`HashMap<String, ArrayList<Integer>> userRatings = new HashMap<String, ArrayList<Integer>>();
 if(!userRatings.containsKey(user)) //The user does not have ratings.
                {
                    ArrayList<Integer> ratings = new ArrayList<Integer>();
                    //                     ratings = userRatings.get(user);
                   for (int j = 0; j < 50; j++)
                    {
                        ratings.add(j);
                    }
                    userRatings.get(user).add(location,value);
}                }
                else //The user has ratings
                {
                    userRatings.get(user).add(location,value);**
                }
                System.out.println(user + " " + userRatings.get(user));
            }
            bufferReader.close();
        }    catch (FileNotFoundException e)
        {
            System.out.println("File does not exist or could not be found.");
        }
        catch (IOException e)
        {
            System.out.println("Can't read from file");
        }
        catch (NullPointerException e)
        {
        }`

The problem I now have is in adding to the arraylist. How would I do that in the bolded areas? — How would I populate and manipulate the arraylist?

  • 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-04T22:45:04+00:00Added an answer on June 4, 2026 at 10:45 pm

    To be honest, I think the initial problem is in reading the file in
    that format.

    This is easy if you use the right library. Take a look at this one: http://opencsv.sourceforge.net/, which is meant to parse csv files. From that site:

    Can I use my own separators and quote characters?

    Yes. There are
    constructors that cater for supplying your own separator and quote
    characters. Say you’re using a tab for your separator, you can do
    something like this:

    CSVReader reader = new CSVReader(new FileReader("yourfile.csv"), '\t');
    

    I think this is exactly what you’re trying to do. You’re asking this library to parse the input file with tab-delimited values instead of comma-delimited. From your example above, that seems to be what your input format is.

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

Sidebar

Related Questions

So I have a file that looks like this: 1st 2nd­ nth e1­, ­­v1,
I have a .plist file that looks like this: <plist version=1.0> <array> <dict> <key>name</key>
i have a file that looks like this: TTITLE0=track name 1 TTITLE1=track name 2
I have a XML file that looks like this <Licence> <Name>Test company</Name> <Version>1.1.1.1</Version> <NumberOfServer>2</NumberOfServer>
I have a file that looks like this ID Name Car 1 Mike Honda
I have a file that looks like this: @Afghanistan.png, @Albania.png, @Algeria.png, @American_Samoa.png, I want
i have a file that looks like this: sdfkhsdf,sdfgsg,sdfsdf,sdsdf sdfsdf,43534,sdfsdf,24234,sfddsf efsdf,234234,sdfsdf,234234,sadfsdf i need to
i have xml file that looks like this: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE pointList SYSTEM
I have a file that looks like this: ID1 ID2 3 ID2 ID3 3
I have a file that contain lines that looks like this: >AF001546_1 [88 -

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.