Skip to content

Conversation

lukapeschke
Copy link
Collaborator

@lukapeschke lukapeschke commented Aug 28, 2025

This allows to use fastexcel from rust. It can be used to generate Fastexcel columns, which are simple wrappers around owned data.

An optional polars extra allows to convert an ExcelSheet or an ExcelTable to a DataFrame.

Different cargo features have been added to distinguish between Python and Rust builds, as we don't need arrow for rust usage (polars ships its own implem when enabled)

See rust integration tests for usage examples

Signed-off-by: Luka Peschke <[email protected]>
Signed-off-by: Luka Peschke <[email protected]>
Signed-off-by: Luka Peschke <[email protected]>
Signed-off-by: Luka Peschke <[email protected]>
Signed-off-by: Luka Peschke <[email protected]>
@lukapeschke lukapeschke self-assigned this Aug 28, 2025
@lukapeschke lukapeschke added 🔨 WIP 🔧 🦀 rust 🦀 Pull requests that edit Rust code 🐻 polars 🐻 Polars-related issues labels Aug 28, 2025
@lukapeschke lukapeschke marked this pull request as ready for review August 28, 2025 16:44
@lukapeschke lukapeschke requested a review from PrettyWood August 28, 2025 16:44
Signed-off-by: Luka Peschke <[email protected]>
Copy link

@Fanaen Fanaen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really neat! 🙏

Only a couple minor nitpicks.
My review is rather shallow as I'm not used to this project yet.
Another review would be appreciated!

&& data_len != len
{
return Err(FastExcelErrorKind::InvalidColumn(format!(
"Column '{name}' has length {data_len} but expected {len}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick(non-blocking)

Suggested change
"Column '{name}' has length {data_len} but expected {len}"
"column '{name}' has length {data_len} but expected {len}"

fn build_selected_columns(
use_columns: Option<&Bound<'_, PyAny>>,
) -> FastExcelResult<SelectedColumns> {
use_columns.try_into().with_context(|| format!("expected selected columns to be list[str] | list[int] | str | Callable[[ColumnInfo], bool] | None, got {use_columns:?}"))
Copy link

@Fanaen Fanaen Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick(non-blocking)
Case seems different here (uppercase in most src/types/excelreader/mod.rs::ExcelReader)

Copy link
Collaborator

@PrettyWood PrettyWood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very very cool! Looks great overall.
2 main points:

  • add rustdoc comments on main structs, methods,...
  • API improvement on FastExcelSeries
    Not blocking but would love it :)

}

#[derive(Debug, Clone, PartialEq)]
pub struct FastExcelColumn {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add doc

}

#[derive(Debug, Clone, PartialEq)]
pub enum FastExcelSeries {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add doc
I would also impl len() and is_empty + IntoIterator for each variant

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end, I didn't implement those, because the length of a Null Series cannot be known. I added into_$type methods to access the raw data, and the docs recommend to use FastExcelColumn over FastExcelSeries.

@PrettyWood PrettyWood requested a review from Copilot August 29, 2025 21:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds a Rust crate implementation for fastexcel, enabling usage from Rust code in addition to the existing Python interface. The Rust API provides access to Excel sheet and table data through column-based structures, with optional Polars DataFrame integration.

Key changes include:

  • Rust API implementation with FastExcelColumn and FastExcelSeries types
  • Optional Polars integration for DataFrame conversion
  • Feature-based compilation to separate Python and Rust dependencies
  • Restructured codebase to support both Python and Rust usage patterns

Reviewed Changes

Copilot reviewed 34 out of 59 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/lib.rs Exposes public Rust API and maintains Python module compatibility
src/types/mod.rs Restructures type exports for both Python and Rust usage
src/data/mod.rs Implements FastExcelColumn and FastExcelSeries for Rust API
src/types/excelreader/mod.rs Refactors ExcelReader to support both Python and Rust usage
tests/fastexcel.rs Adds comprehensive Rust integration tests

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ToucanToco ToucanToco deleted a comment from Copilot AI Aug 29, 2025
@PrettyWood
Copy link
Collaborator

Also readme needs an update

@ToucanToco ToucanToco deleted a comment from Copilot AI Sep 1, 2025
@ToucanToco ToucanToco deleted a comment from Copilot AI Sep 1, 2025
@lukapeschke
Copy link
Collaborator Author

@PrettyWood A second review would be great, sync with main wasn't easy 🙏

In addition to branch update, I did the following:

  • Added rust docs & rust doc check to the CI
  • Fixed some python typing
  • Made the Rust API for Series/Columns nicer
  • Updated the README

@lukapeschke lukapeschke merged commit afea4a0 into main Sep 1, 2025
23 checks passed
@lukapeschke lukapeschke deleted the add-rust-crate branch September 1, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐻 polars 🐻 Polars-related issues 🦀 rust 🦀 Pull requests that edit Rust code ✋ need review ✋
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants