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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:24:01+00:00 2026-06-05T09:24:01+00:00

I have a few arff files. I would like to read them sequentially and

  • 0

I have a few arff files. I would like to read them sequentially and create a large dataset. Instances.add(Instance inst) doesn’t add string values to the instances, hence the attempt to setDataset() … but even this fails. Is there a way to accomplish the intuitively correct thing for strings?

                ArffLoader arffLoader = new ArffLoader();
                arffLoader.setFile(new File(fName));
                Instances newData = arffLoader.getDataSet();
                for (int i = 0; i < newData.numInstances(); i++) {
                        Instance one = newData.instance(i);
                        one.setDataset(data);
                        data.add(one);
                }
  • 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-05T09:24:03+00:00Added an answer on June 5, 2026 at 9:24 am

    This is from mailing list. I saved it before

    how to merge two data file a.arff and b.arff into one data list?

    Depends what merge you are talking about. Do you just want to append
    the second file (both have the same attributes) or do you want to add
    the merge the attributes (both have the same number of instances)?

    In the first case ("append"): 
    java weka.core.Instances append filename1 filename2 > output-file 
    
    and the latter case ("merge"): 
    java weka.core.Instances merge filename1 filename2 > output-file 
    

    Here’s the relevant Javadoc:
    http://weka.sourceforge.net/doc.dev/weka/core/Instances.html#main(java.lang.String%5B%5D)

    Use mergeInstances to merge two datasets.

     public static Instances mergeInstances(Instances first,
                                       Instances second)
    

    Your code would be something like below. For same instance numbers.

    ArffLoader arffLoader = new ArffLoader();
    arffLoader.setFile(new File(fName1));
    Instances newData1 = arffLoader.getDataSet();
    arffLoader.setFile(new File(fName2));
    Instances newData2 = arffLoader.getDataSet();
    Instances mergedData = Instances.mergeInstances( newData1 ,newData2);       
    

    Your code would be something like below. For same attribute numbers. I do not see any java method in weka. If you read code there is something like below.

    // Instances.java
    //  public static void main(String[] args) {
    // read two files, append them and print result to stdout
      else if ((args.length == 3) && (args[0].toLowerCase().equals("append"))) {
    DataSource source1 = new DataSource(args[1]);
    DataSource source2 = new DataSource(args[2]);
    String msg = source1.getStructure().equalHeadersMsg(source2.getStructure());
    if (msg != null)
      throw new Exception("The two datasets have different headers:\n" + msg);
    Instances structure = source1.getStructure();
    System.out.println(source1.getStructure());
    while (source1.hasMoreElements(structure))
      System.out.println(source1.nextElement(structure));
    structure = source2.getStructure();
    while (source2.hasMoreElements(structure))
      System.out.println(source2.nextElement(structure));
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have few texboxt and dropdownlist, which their id would be something like txtName1,
I have a large ARFF file with data that looks something like this: 555,2011-03-13
I have few very large(10GB) xml files, with the following structure. As you can
I have few question in this regard When you create an internet page, does
We have few components like libraries dlls When initially created I ran the following
I have few nested DIVs at page. I want to add event only for
I have few 'so' files that I need to load in maven java project
I have few Vaadin tabs one of them is displaying an table and some
I have few values existing in data base,i need to update them but,i am
i have few variables like this: self.lamp_1 self.lamp_2 self.lamp_3 self.lamp_4 and now i want

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.