Apache Commons CSV Documentation

repository·master·Indexed 19 days ago

https://github.com/apache/commons-csv

A lightweight Java library designed to simplify the reading and writing of various types of CSV and delimited text files. It provides a simple interface and high-level abstractions for handling delimited data.

Tokens
650
Snippets
4
Records
6
Agent score
15%

What's inside Apache Commons CSV

  1. Overview of Apache Commons CSV

    master
    Apache Commons CSV is a Java library that provides a simple interface for reading and writing CSV files of various types. It supports multiple formats and provides high-level abstractions for handling delimited data.
  2. Run the standalone performance test

    master

    If you only want to test the performance of commons-csv specifically, you can run a standalone performance test.

    Warning: Unlike the JMH benchmarks, this test uses simple timing metrics rather than the Java Microbenchmark Harness.

    # Run the performance test
    mvn test -Dtest=PerformanceTest
  3. Install benchmark prerequisites

    master

    Before running benchmarks, you must manually install the Skife CSV implementation into your local Maven repository, as it is not available in Maven Central. Use the provided script to download and install the required JAR file.

    ./benchmark-prereq.sh
  4. Run JMH benchmarks

    master

    Apache Commons CSV uses the Java Microbenchmark Harness (JMH) to compare various CSV processing implementations. You can run all benchmarks or target a specific one using Maven profiles.

    Available benchmark names include:

    • read: Java JDK (BufferedReader line count)
    • scan: Java JDK (Scanner line count)
    • split: Java JDK (BufferedReader delimiter split)
    • parseCommonsCSV: commons-csv (CSVFormat delimiter split)
    • parseGenJavaCSV: generation-java (CsvReader delimiter split)
    • parseJavaCSV: java-csv (CsvReader delimiter split)
    • parseOpenCSV: open-csv (CSVReader delimiter split)
    • parseSkifeCSV: skife-csv (CSVReader delimiter split)
    • parseSuperCSV: super-csv (CsvListReader delimiter split)
    # Run all benchmark tests
    mvn test -Pbenchmark
    
    # Run a specific benchmark test
    mvn test -Pbenchmark -Dbenchmark=<name>
    
    # Example: running the basic "read" benchmark
    mvn test -Pbenchmark -Dbenchmark=read
  5. Install Apache Commons CSV via Maven

    master

    To use Apache Commons CSV in your Java project, add the following dependency to your pom.xml file to pull it from the central Maven repositories.

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-csv</artifactId>
      <version>1.14.1</version>
    </dependency>