2 releases

0.1.1 Oct 21, 2024
0.1.0 Feb 15, 2024

#2950 in Parser implementations

Download history 21/week @ 2024-07-13 38/week @ 2024-07-20 14/week @ 2024-07-27 9/week @ 2024-08-03 16/week @ 2024-08-10 101/week @ 2024-08-17 69/week @ 2024-08-24 32/week @ 2024-08-31 13/week @ 2024-09-07 36/week @ 2024-09-14 79/week @ 2024-09-21 215/week @ 2024-09-28 145/week @ 2024-10-05 72/week @ 2024-10-12 309/week @ 2024-10-19 49/week @ 2024-10-26

717 downloads per month
Used in datavzrd

MIT license

17KB
308 lines

GitHub Workflow Status codecov

readervzrd

Readervzrd is a Rust library that provides utilities for reading tabular data from files without worrying if they are formatted as CSV or JSON. It offers flexible functionality to extract headers and iterate over records, supporting different file formats and structures.

Features

  • Supports uniform reading of data from CSV and JSON files.
  • Extracts headers from files.
  • Iterate over records
  • Handling of nested JSON structures

Installation

To use readervzrd in your Rust project, add it as a dependency in your Cargo.toml file:

[dependencies]
readervzrd = "0.1.0"

Usage

use readervzrd::{FileReader, FileError};

fn main() -> Result<(), FileError> {
    // Create a FileReader for a CSV file with ',' delimiter
    let mut reader = FileReader::new("data.csv", Some(','))?;

    // Create another FileReader for a JSON file
    let mut another_reader = FileReader::new("data.json", None)?;

    // Get headers from the file
    let headers = reader.headers()?;
    println!("Headers: {:?}", headers);

    // Iterate over records and process them
    for record in reader.records()? {
        println!("Record: {:?}", record);
    }

    Ok(())
}

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or create a pull request on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Dependencies

~1.7–2.6MB
~42K SLoC