jmcnamara / polars_excel_writer

A Polars extension to serialize dataframes to Excel xlsx files
Apache License 2.0
13 stars 4 forks source link

migration for release of polars 0.36.2 #16

Closed GuillaumePressiat closed 7 months ago

GuillaumePressiat commented 7 months ago

Hi,

Thanks for your work.

Don't know if it will help a bit.

Small changes to adapt this work for polars 0.36.2

Biggest change is to replace Utf8 to String in src/xlsx_writer.rs

tests are ok and exports in xlsx works fine for me using polars_excel_writer::ExcelWriter

First I've changed the version in rust_xlsxwriter here too but haven't pull request it since it's really a minor change.

jmcnamara commented 7 months ago

First I've changed the version in rust_xlsxwriter here too but haven't pull request it since it's really a minor change.

That is okay. Go ahead and submit that as a PR against rust_xlsxwriter. I can't accept this PR as it is if it points to your version of rust_xlsxwriter. After that you can revise the Cargo.toml change to point to https://github.com/jmcnamara/rust_xlsxwriter

Biggest change is to replace Utf8 to String in src/xlsx_writer.rs

Out of curiosity when did this change in Polars?

GuillaumePressiat commented 7 months ago

Ok!

Out of curiosity when did this change in Polars?

see here https://github.com/pola-rs/polars/releases/tag/rs-0.36.2

and here precisely https://github.com/pola-rs/polars/pull/13224

jmcnamara commented 7 months ago

Ran, the polars_excel_writer too early. Will rerun after the rust_xlsxwriter merge.

GuillaumePressiat commented 7 months ago

Ran, the polars_excel_writer too early. Will rerun after the rust_xlsxwriter merge.

thanks

jmcnamara commented 7 months ago

Merged thanks.

Do you have any feedback on your use case or usage? I'm interested to see how/why people are using it.

GuillaumePressiat commented 7 months ago

Hi,

My use case is really simple (I'm a rust newbie, coming from R and Python).

My source files are fwf txt files that I parse/split into multiples LazyFrames polars. Then I have a hashmap of these LazyFrames and I export these to a parameterized format among csv, json, parquet, and by now xlsx thanks to your work.

With something like this:

if !["csv", "parquet", "json", "xlsx"].contains(&extension) {
    panic!("Extension {} non pris en charge", extension)
}
if extension == "csv" {
    CsvWriter::new(&mut output_file).finish(&mut data).unwrap();
} else if extension == "parquet" {
    ParquetWriter::new(&mut output_file)
        .finish(&mut data)
        .unwrap();
} else if extension == "json" {
    JsonWriter::new(&mut output_file).finish(&mut data).unwrap();
} else if extension == "xlsx" {
    use polars_excel_writer::ExcelWriter;

    ExcelWriter::new(&mut output_file)
        .finish(&mut data)
        .unwrap();
}

I've seen that with rust_xlsxwriter it's possible to do charts and so on, I will look at this. Maybe extend formatting and filtering tables in Excel directly too.

I'll have to take a look at examples drectory.