Crate dataload

Crate dataload 

Source
Expand description

§dataload

A flexible library for loading CSV and Excel files into Polars DataFrames.

dataload provides automatic file type detection, intelligent delimiter detection for CSV files, and a builder-pattern API for customizing how files are loaded.

§Features

  • Automatic file type detection via magic bytes and file extensions
  • Smart delimiter detection for CSV files (comma, tab, semicolon, pipe)
  • Excel support for xlsx, xls, xlsm, xlsb, and ods formats
  • Builder-pattern API for flexible configuration
  • Zero-copy where possible using Polars DataFrames

§Quick Start

use dataload::DataLoader;

// Load from bytes with automatic detection
let csv_data = b"name,age,city\nAlice,30,NYC\nBob,25,LA";
let df = DataLoader::new()
    .load_bytes(csv_data, "people.csv")?;

assert_eq!(df.shape(), (2, 3));

§Loading Files

use dataload::{DataLoader, load_file};
use std::path::Path;

// Using the convenience function
let df = load_file(Path::new("data.csv"))?;

// Or with custom options
let df = DataLoader::new()
    .with_header(false)
    .with_skip_rows(1)
    .load_file(Path::new("data.csv"))?;

§Custom Delimiters

use dataload::{DataLoader, Delimiter};

// Force a specific delimiter
let tsv_data = b"col1\tcol2\n1\t2";
let df = DataLoader::new()
    .with_delimiter(Delimiter::Tab)
    .load_bytes(tsv_data, "data.tsv")?;

§Excel Files

Excel support requires the excel feature (enabled by default):

use dataload::DataLoader;
use std::path::Path;

let df = DataLoader::new()
    .with_sheet_name("Sales")
    .load_file(Path::new("report.xlsx"))?;

§Feature Flags

  • csv (default): CSV/TSV file support
  • excel (default): Excel file support (xlsx, xls, etc.)

To disable Excel support and reduce dependencies:

[dependencies]
dataload = { version = "0.1", default-features = false, features = ["csv"] }

Re-exports§

pub use csv::load_csv_with_fallback;

Modules§

csv
CSV file loading implementation.
prelude
Prelude module for convenient imports.

Structs§

DataFrame
A contiguous growable collection of Series that have the same length.
DataLoader
A flexible data loader for CSV and Excel files.
LoadOptions
Configuration options for loading data files.

Enums§

DataLoadError
All errors that can occur during data loading operations.
Delimiter
Supported delimiters for CSV files.
FileType
Supported file types for data loading.

Functions§

list_sheets
Returns the list of sheet names in an Excel file.
load_bytes
Convenience function to load bytes with default options.
load_file
Convenience function to load a file with default options.

Type Aliases§

Result
A specialized Result type for dataload operations.