[][src]Crate rustsv

What is RustSV?

RustSV (referred to as RSV) is a CSV parser, built for the modern age.

It focuses on usability, and has the advantage of not requiring the use of Serde to parse your files into a programmatically readable structure.

See the source code here

Found a bug? report it!

Basic usage:

Parsing a string:

use rustsv::prelude::*;
// Create our input data
let input: &str = "surname,initial,address,phone number\n\
Smith,A,\"14 Made up Drive, Made up City, Ohio\",216-235-3744\n\
Doe,J,\"15 Fake Street, Phonyville, Texas\",210-214-5737";

// Parse the `input` into `Content`
// The parameters are as follows:
// 1. Input: String   - The text you wish to parse
// 2. Delimiter: Char - The character to delimit by
// 3. Headers: Bool   - If the parser should use the first row in the file as headers
let content: Content = parse(input, ',', true);

The above method will provide an instance of Content

Parsing a file:

Note: this code is correct at the time of documentation, it has the no_run tag to ensure the doc tests do not fail due to an unavoidable IO Error

use rustsv::prelude::*;

// Parse the `path`'s content into `Content`
// The parameters are as follows:
// 1. Path: String   - The text you wish to parse
// 2. Delimiter: Char - The character to delimit by
// 3. Headers: Bool   - If the parser should use the first row in the file as headers
let content: Content = read("path/to/file.csv", ',', true)?;

The above method will provide a result containing an error, or Content

Parsing a remote file, from a URL:

This method requires the http feature to be anabled.

Note: this code is correct at the time of documentation, it has the no_run tag to ensure the doc tests do not fail due to an unavoidable IO Error

use rustsv::prelude::*;
// Parse the `URL`'s content into `Content`
// The parameters are as follows:
// 1. URL: String   - The text you wish to parse
// 2. Delimiter: Char - The character to delimit by
// 3. Headers: Bool   - If the parser should use the first row in the file as headers
let content: Content = fetch("https://domain.tld/path/to/file", ',', true)?;

The above method will provide a result containing an error, or Content

Re-exports

pub use crate::structs::Entry;
pub use crate::structs::Content;

Modules

prelude
structs

Functions

parse

Parses the provided String into an instance of Content

read

Reads a file and parses it into an instance of Content