<commit_before>package org.basex.examples.create;

import org.basex.core.BaseXException;
import org.basex.core.Context;
import org.basex.core.Prop;
import org.basex.core.proc.CreateDB;
import org.basex.core.proc.DropDB;
import org.basex.core.proc.Set;
import org.basex.core.proc.XQuery;

/**
 * This example demonstrates how to import a file in the CSV format
 * into the database.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-10, ISC License
 * @author <NAME>
 */
public final class CSVExample {
  /** Private constructor. */
  private CSVExample() { }

  /**
   * Main test method.
   * @param args command-line arguments
   * @throws BaseXException if a database command fails
   */
  public static void main(final String[] args) throws BaseXException {

    System.out.println("=== CSVExample ===");

    // ------------------------------------------------------------------------
    // Create database context
    final Context ctx = new Context();

    // input file and name of database
    final String file = "etc/example.csv";
    final String name = "csvexample";

    // ------------------------------------------------------------------------
    // Import the specified file
    System.out.println("\n* Import '" + file + "'.");

    new Set(Prop.PARSER, "csv").execute(ctx);
    new CreateDB(file, name).execute(ctx);

    // ------------------------------------------------------------------------
    // Perform query
    System.out.println("\n* Number of records:");

    new XQuery("count(//record)").execute(ctx, System.out);

    // ------------------------------------------------------------------------
    // Drop database and close context
    System.out.println("\n\n* Drop database.");

    new DropDB(name).execute(ctx);
    ctx.close();
  }
}<commit_msg>CSV fix, MemBuilder.build() rewrite<commit_after>package org.basex.examples.create;

import org.basex.core.BaseXException;
import org.basex.core.Context;
import org.basex.core.proc.CreateDB;
import org.basex.core.proc.DropDB;
import org.basex.core.proc.Set;
import org.basex.core.proc.XQuery;

/**
 * This example demonstrates how to import a file in the CSV format
 * into the database.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-10, ISC License
 * @author <NAME>
 */
public final class CSVExample {
  /** Private constructor. */
  private CSVExample() { }

  /**
   * Main test method.
   * @param args command-line arguments
   * @throws BaseXException if a database command fails
   */
  public static void main(final String[] args) throws BaseXException {

    System.out.println("=== CSVExample ===");

    // ------------------------------------------------------------------------
    // Create database context
    final Context ctx = new Context();

    // input file and name of database
    final String file = "etc/example.csv";
    final String name = "csvexample";

    // ------------------------------------------------------------------------
    // Import the specified file
    System.out.println("\n* Import '" + file + "'.");

    new Set("parser", "csv").execute(ctx);
    new CreateDB(file, name).execute(ctx);

    // ------------------------------------------------------------------------
    // Perform query
    System.out.println("\n* Number of records:");

    new XQuery("count(//record)").execute(ctx, System.out);

    // ------------------------------------------------------------------------
    // Drop database and close context
    System.out.println("\n\n* Drop database.");

    new DropDB(name).execute(ctx);
    ctx.close();
  }
}
{'fraction_non_alphanumeric': 0.2779481460830778, 'fraction_numerical': 0.003345413994981879, 'mean_word_length': 1.707924528301887, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3628968', 'n_tokens_mistral': 957, 'n_tokens_neox': 913, 'n_words': 259}