Expand description
§use-csv
Practical CSV utility primitives for lightweight delimiter detection, field escaping, and row splitting.
Warning: versions below
0.3.0are experimental and may change as the crate matures.
§Example Usage
use use_csv::{csv_join_row, detect_delimiter, parse_csv_basic, split_csv_line_basic};
let rows = parse_csv_basic("name,enabled\nRustUse,true\n");
assert_eq!(detect_delimiter("name;enabled\nRustUse;true\n"), Some(';'));
assert_eq!(split_csv_line_basic("a,\"b,c\",d"), vec!["a", "b,c", "d"]);
assert_eq!(rows[1].fields[0], "RustUse");
assert_eq!(csv_join_row(&["one", "two,three"]), "one,\"two,three\"");§Scope
- common delimiter detection for comma, tab, semicolon, and pipe separated data
- conservative quoted-field splitting
- lightweight row parsing for fixtures, CLIs, docs, and config helpers
§Non-Goals
- full RFC 4180 support
- streaming CSV parsing
- encoding detection
§License
Licensed under either of the following, at your option:
- MIT License
- Apache License, Version 2.0
Structs§
- CsvDialect
- Basic dialect metadata for simple CSV handling.
- CsvRow
- A parsed CSV row.
Functions§
- count_
csv_ columns - Counts columns in a CSV-like line using the basic splitter.
- csv_
escape_ field - Escapes a field for comma-separated output.
- csv_
join_ row - Joins fields into a comma-separated row.
- detect_
delimiter - Detects the most likely delimiter from common candidates.
- looks_
like_ csv - Returns
truewhen the input looks like delimiter-separated data. - parse_
csv_ basic - Parses CSV-like input into rows without streaming or encoding support.
- split_
csv_ line_ basic - Splits a single CSV line using a detected delimiter or a comma fallback.