csvrow 0.2.2

Fast and simple crate for taking a string slice and iterating over the fields in a manner that adheres to RFC-4180
Documentation
  • Coverage
  • 28.57%
    2 out of 7 items documented2 out of 3 items with examples
  • Size
  • Source code size: 13.43 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 446.71 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • RetrospectionSoftware/csvrow
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • RetrospectionSoftware

csvrow

=== A small, fast utility library that allows you to wrap a string slice representing a line from a CSV file and iterate over its fields. Complies with RFC 4180 (CSV format) and UTF8.

Usage

Add csvrow to your Cargo.toml file directly, or alternatively type cargo add csvrow at a terminal prompt in your project root.

Example

Creating a CSV Row from a String slice and collecting the results into a Vec:

use CsvRow::*;

fn get_fields() {

    let row = "rust,is,awesome";
    let csv = CsvRow::new(row, ',', false);
    let vec_t: Vec<_> = csv.collect();
}

Fields wrapped in quotes, or containing escaped quotes (in accordance with RFC 4180) will by default be parsed and un-escaped. This behavior can be overridden with the 'literal' parameter of CsvRow::new

use CsvRow::*;

fn get_fields() {

    let row = r#""rust",is,"Awesome ""bring me the"" Sauce""#;
    let csv = CsvRow::new(row, ',', false);
    let vec_t: Vec<_> = csv.collect();

    // Will yield:
    // rust
    // is
    // Awesome "bring me the" Sauce

    let row = r#""rust",is,"Awesome ""bring me the"" Sauce""#;
    let csv = CsvRow::new(row, ',', true);
    let vec_t: Vec<_> = csv.collect();

    // Will yield:
    // "rust"
    // is
    // "Awesome ""bring me the"" Sauce"
}

License: Unlicense/MIT