Function cc2p::convert_to_parquet

source ·
pub fn convert_to_parquet(
    file_path: &PathBuf,
    delimiter: char,
    has_header: bool,
    sampling_size: u16,
) -> Result<(), Box<dyn Error>>
Expand description

Converts a CSV file to Parquet format.

§Arguments

  • file_path - The path of the CSV file to be converted.
  • delimiter - The delimiter character used in the CSV file.
  • has_header - Indicates whether the CSV file has a header row.
  • sampling_size - The number of rows to sample for inferring the schema.

§Returns

Returns Ok if the conversion is successful, otherwise returns an Err with a Box<dyn std::error::Error>.

§Example

use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    use cc2p::convert_to_parquet;

    let file_path = PathBuf::from("testdata/sample.csv");
    let delimiter = ',';
    let has_header = true;

    convert_to_parquet(&file_path, delimiter, has_header, 10)?;

    Ok(())
}