Skip to main content

No project description provided

Project description

Easy Excel Management

Rust-powered Python module for Excel manipulation

Installation

Classic through pip or your favourite package manager:

pip install ez-excel-mgt

Usage

Create an Excel file test.xlsx with a few rows and columns in a sheet named "Sheet1". Sheet name must match exactly the name you'll use in the code. Last row should contain the headers, i.e. the column names in the dataframe ("Name" and "Age" in this example). Pay attention to the column names: they must match exactly the column names in the dataframe.

import pandas as pd
import polars as pl
import ez_excel_mgt as ezex

# Define the sheet name and Excel file path
sheet_name = "Sheet1"
excel_file_path = "template.xlsx"

# Create a Pandas DataFrame
df_pandas = pd.DataFrame({
    "Name": ["Alice", "Bob", "Charlie"],
    "Age": [25, 30, 35]
})

# Call the function to append the DataFrame to the existing sheet using column names located at row 3
ezex.fill_sheet_with(excel_file_path, sheet_name, df_pandas, named=True, header_row=3)

# Create a Polars DataFrame
df_polars = pl.DataFrame({
    "Name": ["Philippe", "Anatole"],
    "Age": [65, 90]
})

# Call the function to write the DataFrame to the existing sheet and overwrite existing data (but not deleting rows beyond)
ezex.fill_sheet_with(excel_file_path, sheet_name, df_polars, named=True, header_row=3, overwrite=True)

df_dict = {
    "Name": ["Mirlinda", "Emilie"],
    "Age": [35, 40]
}

# Call the function to write the DataFrame to the existing sheet and overwrite existing data as of row 6
ezex.fill_sheet_with(excel_file_path, sheet_name, df_dict, named=True, header_row=3, overwrite=True, start_row=6)

Options

  • named: if the dataframe columns are named (default: False).
  • header_row: the row number of the column names (default: 1). Can be set to last, first or be an integer > 0.
  • overwrite: if the data should be overwritten if it exists (default: False).
  • start_row: the row number to start writing the data (must be greater than the header row). Can be set to last, first or be an integer > 0.
  • strict: if numbers of columns must match (if not named) or if columns names must match (if named). Otherwise, if not named, the number of columns in the dataframe must be lower or equal to the number of columns in the excel sheet, else all columns of the dataframe must be found in the excel sheet.
import pandas as pd
import ez_excel_mgt as ezex

# Create a Pandas DataFrame
df = pd.DataFrame({
    "Name": ["Alice", "Bob", "Charlie"],
    "Age": [25, 30, 35]
})

# Define the sheet name and Excel file path
sheet_name = "Sheet1"
excel_file_path = "template.xlsx"

# Call the function to write the DataFrame to the existing sheet
ezex.will_sheet_with(excel_file_path, sheet_name, df, named=True, header_row=3, overwrite=True, start_row=4)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ez_excel_mgt-0.4.1.tar.gz (76.5 kB view hashes)

Uploaded Source

Built Distributions

ez_excel_mgt-0.4.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl (5.3 MB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

ez_excel_mgt-0.4.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl (5.3 MB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

ez_excel_mgt-0.4.1-pp38-pypy38_pp73-macosx_11_0_arm64.whl (5.3 MB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

ez_excel_mgt-0.4.1-cp312-cp312-macosx_11_0_arm64.whl (5.3 MB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

ez_excel_mgt-0.4.1-cp311-cp311-macosx_11_0_arm64.whl (5.2 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

ez_excel_mgt-0.4.1-cp310-cp310-macosx_11_0_arm64.whl (5.3 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page