|
| 1 | +# FastCSV |
| 2 | + |
| 3 | +> Fast, lightweight, and easy to use — the production-proven CSV library for Java. |
| 4 | + |
| 5 | +FastCSV is the most-starred CSV library for Java. It is a high-performance CSV parser and writer, licensed under MIT. Requires Java 17+ (Android 14 / API level 34). |
| 6 | + |
| 7 | +## Key Features |
| 8 | + |
| 9 | +- **Fast CSV processing** — optimized for high-speed reading and writing |
| 10 | +- **Tiny footprint** — only ~90 KiB, with zero runtime dependencies |
| 11 | +- **Developer-friendly API** — clean, intuitive, null-free, and easy to integrate |
| 12 | +- **Well-documented** — quickstart guides and complete Javadoc |
| 13 | +- **High test coverage** — including mutation testing for reliability |
| 14 | +- **RFC 4180 compliant** — handles edge cases correctly |
| 15 | +- **Robust & maintainable** — uses SpotBugs, PMD, Error Prone, NullAway, and Checkstyle; never returns null unexpectedly |
| 16 | +- **Secure** — fuzz-tested via OSS-Fuzz and following OpenSSF best practices |
| 17 | +- **Production-proven** — trusted by open-source projects like JUnit, Apache NiFi, and Neo4j |
| 18 | +- **Java 17+, Android 34+ compatible** — including GraalVM Native Image and OSGi |
| 19 | +- Configurable field separators, quote strategies, and comment handling |
| 20 | +- BOM (Byte Order Mark) support (UTF-8, UTF-16, UTF-32) |
| 21 | +- Header record support with named field access |
| 22 | +- Random access reading via IndexedCsvReader |
| 23 | +- Flexible callback handlers for custom record types |
| 24 | +- Field modifiers for trimming and transforming values during parsing |
| 25 | + |
| 26 | +## Quick Start |
| 27 | + |
| 28 | +Writing CSV: |
| 29 | + |
| 30 | +```java |
| 31 | +try (CsvWriter csv = CsvWriter.builder().build(Path.of("output.csv"))) { |
| 32 | + csv |
| 33 | + .writeRecord("header 1", "header 2") |
| 34 | + .writeRecord("value 1", "value 2"); |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +Reading CSV: |
| 39 | + |
| 40 | +```java |
| 41 | +try (CsvReader<CsvRecord> csv = CsvReader.builder().ofCsvRecord(Path.of("input.csv"))) { |
| 42 | + csv.forEach(IO::println); |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +## Documentation |
| 47 | + |
| 48 | +- [Quick Start Guide](https://fastcsv.org/guides/quickstart/): Add the Maven/Gradle dependency and write your first CSV reader and writer in Java. |
| 49 | +- [Basic Tutorial](https://fastcsv.org/guides/basic/): Learn reading and writing CSV files with CsvReader, IndexedCsvReader, and CsvWriter. |
| 50 | +- [Design Goals](https://fastcsv.org/architecture/goals/): Core design goals — performance, lightweight, compliance, simplicity, robustness, security. |
| 51 | +- [Architecture](https://fastcsv.org/architecture/architecture/): Technical architecture covering reader and writer components. |
| 52 | +- [CSV Interpretation](https://fastcsv.org/architecture/interpretation/): How FastCSV interprets CSV data per RFC 4180-bis. |
| 53 | +- [FAQ](https://fastcsv.org/faq/): Frequently asked questions about FastCSV. |
| 54 | +- [Upgrading](https://fastcsv.org/guides/upgrading/): Guide for migrating from FastCSV 3.x to 4.x. |
| 55 | +- [Compliance Report](https://fastcsv.org/compliance/): RFC 4180 compliance verification results. |
| 56 | +- [Other Libraries](https://fastcsv.org/other-libraries/): Comparison with alternative Java CSV libraries. |
| 57 | +- [Contribution Guide](https://fastcsv.org/guides/contribution/): How to contribute to FastCSV. |
| 58 | + |
| 59 | +## Examples |
| 60 | + |
| 61 | +- [Bean Mapping](https://fastcsv.org/guides/examples/bean-mapping/): Map CSV records to Java beans using NamedCsvRecord. |
| 62 | +- [Byte Order Mark](https://fastcsv.org/guides/examples/byte-order-mark/): Handle BOM headers when reading CSV files. |
| 63 | +- [Compressed CSV](https://fastcsv.org/guides/examples/compressed-csv/): Read and write GZIP-compressed CSV files. |
| 64 | +- [Custom Callback Handler](https://fastcsv.org/guides/examples/custom-callback-handler/): Build custom record types with CsvCallbackHandler. |
| 65 | +- [Handle Comments](https://fastcsv.org/guides/examples/handle-comments/): Read and write CSV files with comment lines. |
| 66 | +- [Indexed Reading](https://fastcsv.org/guides/examples/indexed-read/): Random access and paginated reading of large CSV files. |
| 67 | +- [Modifying Input](https://fastcsv.org/guides/examples/modifying-input/): Trim and transform field values during parsing. |
| 68 | +- [Non-standard Control Characters](https://fastcsv.org/guides/examples/non-standard-control-characters/): Configure custom separators and enclosure characters. |
| 69 | +- [Quote Strategies](https://fastcsv.org/guides/examples/quote-strategies/): Control quoting behavior with QuoteStrategy API. |
| 70 | +- [Read from Classpath](https://fastcsv.org/guides/examples/read-from-classpath/): Read CSV files from the Java classpath. |
| 71 | +- [Reading Ambiguous Data](https://fastcsv.org/guides/examples/reading-ambiguous-data/): Handle empty lines, missing fields, and extra fields. |
| 72 | +- [Reading as String Arrays](https://fastcsv.org/guides/examples/reading-as-string-array/): Reduce overhead with StringArrayHandler. |
| 73 | +- [Reading Null Values](https://fastcsv.org/guides/examples/reading-null/): Handle null and empty values with FieldModifier. |
| 74 | +- [Skip Non-CSV Head](https://fastcsv.org/guides/examples/skip-non-csv-head/): Skip non-CSV header lines at the beginning of files. |
| 75 | +- [PostgreSQL Interoperability](https://fastcsv.org/guides/examples/postgresql-interoperability/): Import/export CSV data with PostgreSQL COPY command. |
| 76 | +- [Writing Rolling Files](https://fastcsv.org/guides/examples/writing-rolling-files/): Split large CSV output across multiple files. |
| 77 | + |
| 78 | +## API Reference |
| 79 | + |
| 80 | +- [Javadoc](https://javadoc.io/doc/de.siegmar/fastcsv/): Full API documentation. |
| 81 | +- [Maven Central](https://central.sonatype.com/artifact/de.siegmar/fastcsv): Maven artifact `de.siegmar:fastcsv`. |
| 82 | +- [GitHub Repository](https://github.com/osiegmar/FastCSV): Source code, issues, and changelog. |
0 commit comments