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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:10:12+00:00 2026-06-04T19:10:12+00:00

Currently, I’m copying one instance at a time from one dataset to the other.

  • 0

Currently, I’m copying one instance at a time from one dataset to the other. Is there a way to do this so that string mappings remain intact? The mergeInstances works horizontally, is there an equivalent vertical merge?

This is one step of a loop I use to read datasets of the same structure from multiple arff files into one large dataset. There has got to be a simpler way.

Instances iNew = new ConverterUtils.DataSource(name).getDataSet();
for (int i = 0; i < iNew.numInstances(); i++) {
    Instance nInst = iNew.instance(i);
    inst.add(nInst);
}
  • 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-04T19:10:13+00:00Added an answer on June 4, 2026 at 7:10 pm

    Why not make a new ARFF file which has the data from both of the originals? A simple

    cat 1.arff > tmp.arff
    tail -n+20 2.arff >> tmp.arff
    

    where 20 is replaced by however many lines long your arff header is. This would then produce a new arff file with all of the desired instances, and you could read this new file with your existing code:

    Instances iNew = new ConverterUtils.DataSource(name).getDataSet();
    

    You could also invoke weka on the command line using this documentation: http://old.nabble.com/how-to-merge-two-data-file-a.arff-and-b.arff-into-one-data-list–td22890856.html

    java weka.core.Instances append filename1 filename2 > output-file 
    

    However, there is no function in the documentation http://weka.sourceforge.net/doc.dev/weka/core/Instances.html#main%28java.lang.String which will allow you to append multiple arff files natively within your java code. As of Weka 3.7.6, the code that appends two arff files is this:

         // 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));
      }
    

    Thus it looks like Weka itself simply iterates through all of the instances in a data set and prints them, the same process your code uses.

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

Sidebar

Related Questions

Currently, I am copying a database from my assets folder to the to the
Currently, my ListViews look like this: How can I achieve that Windows 7 native
Currently playing about with KnockoutJS. Just trying to update an observable array from a
Currently i am consuming web service from android by the method SOAP.Here i need
Currently I have a UITableview, I have enough data that cannot be shown entirely
Currently I am debugging the signing of an Android app. And this would be
Currently, my MVC 3 app has a dependency on a static class that is
Currently, I have a log file of messages in one table in a MySQL
Currently, Enum.Parse supports only the comma as the value separator, so that MemberOne,MemberThree will
Currently I am borrowing java.math.BigInteger from the J# libraries as described here . Having

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.