csv_plus library
Complete, high-performance CSV package for Dart.
This is the main entry point: a single import gives access to encoding, decoding, table manipulation, querying, and transforms.
Quick Start
import 'package:csv_plus/csv_plus.dart';
// Encode
final csv = CsvCodec().encode([['name', 'age'], ['Alice', 30]]);
// Decode with type inference
final rows = CsvCodec().decode(csv); // [['name', 'age'], ['Alice', 30]]
// Full table manipulation
final table = CsvTable.parse(csv);
table.sortBy('age');
table.where((row) => row['age'] > 25);
print(table.avg('age'));
Library Modules
For selective imports, use the individual library files:
| Library | Import |
|---|---|
| Core config & exceptions | package:csv_plus/core.dart |
| Codec facade | package:csv_plus/codec.dart |
| Encoders | package:csv_plus/encoder.dart |
| Decoders | package:csv_plus/decoder.dart |
| Table & schema | package:csv_plus/table.dart |
| Filtering & sorting | package:csv_plus/query.dart |
| Manipulation & aggregation | package:csv_plus/transform.dart |
| File I/O (dart:io) | package:csv_plus/io.dart |
File I/O
File operations require dart:io and must be imported separately:
import 'package:csv_plus/io.dart';
final table = await CsvFile.read('data.csv');
Classes
- CsvCodec
- Main facade for CSV encoding and decoding.
- CsvCodecAdapter
-
A
dart:convertcompatible Codec for CSV data. - CsvColumn
- Describes a column in a CsvTable.
- CsvColumnDef
- Defines a single column's constraints.
- CsvConfig
- Immutable configuration for CSV encoding/decoding.
- CsvDecoder
- Streaming CSV decoder using a chunked state machine.
- CsvEncoder
- Streaming CSV encoder that transforms rows to CSV string chunks.
- CsvRow
- A single CSV row with header-aware, dual-mode access.
- CsvSchema
- Defines constraints for CSV table validation.
- CsvTable
- 2D CSV data structure with headers and data rows.
- FastDecoder
-
High-performance batch CSV decoder using byte-level (
codeUnits) parsing. - FastEncoder
- High-performance batch CSV encoder using per-call StringBuffer.
Enums
- CsvCharset
- Character encoding used when decoding CSV bytes into text.
- CsvDateOrder Configuration
-
How to read a numeric date whose field order is ambiguous, such as
03/04/2024. - QuoteMode
- When to quote fields during CSV encoding.
Extensions
- CsvTableAggregation on CsvTable
- Aggregation operations on CsvTable.
- CsvTableFiltering on CsvTable
- Filtering and querying operations on CsvTable.
- CsvTableManipulation on CsvTable
- Column and row manipulation operations on CsvTable.
- CsvTableSorting on CsvTable
- Sorting operations on CsvTable.
- FastDecoderFlexible on FastDecoder
- Flexible and typed decode operations for FastDecoder.
Constants
Typedefs
- ColumnDef = CsvColumnDef
- Former name of CsvColumnDef, kept for source compatibility.
Exceptions / Errors
- CsvException
- Base exception for all CSV operations.
- CsvParseException
- Thrown when CSV input cannot be parsed.
- CsvValidationException
- Thrown when CSV data fails CsvSchema validation.