Skip to content

A fast Excel reader and writer for Python, with writer functionality added

License

Notifications You must be signed in to change notification settings

bryanhan1001/fastexcel-rw

Repository files navigation

fastexcel-rw

License Python Rust Performance

This is a fork of ToucanToco/fastexcel with Excel writing functionality added.

🚀 What's New

This fork extends the original fastexcel library with:

  • Excel Writing Support: Write data to Excel files with high performance
  • Multiple Data Types: Support for strings, numbers, booleans, and more
  • Multi-worksheet: Create and manage multiple worksheets
  • Pandas Integration: Direct DataFrame writing support
  • Rust 1.88.0 Support: Updated to latest Rust version

📈 Performance

  • 3.8x faster than Python xlsxwriter
  • 9.4x faster than openpyxl
  • Memory efficient with Rust's zero-copy design

🔧 Installation

Quick Install from GitHub

pip install git+https://github.com/bryanhan1001/fastexcel-rw.git

Install from Source

# Clone the repository
git clone https://github.com/bryanhan1001/fastexcel-rw.git
cd fastexcel-rw

# Install with writer feature
maturin develop --features writer

# Or build wheel
maturin build --features writer

💻 Usage

Writing Excel Files

import fastexcel

# Create writer
writer = fastexcel.create_excel_writer("output.xlsx")

# Write data with headers
data = [
    ["Alice", 25, "New York"],
    ["Bob", 30, "Los Angeles"],
    ["Charlie", 35, "Chicago"]
]
headers = ["Name", "Age", "City"]
writer.write_sheet_data(data, "Sheet1", headers)

# Save file
writer.save()

Writing DataFrames

import pandas as pd
import fastexcel

# Create DataFrame
df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35],
    'City': ['New York', 'Los Angeles', 'Chicago']
})

# Write to Excel
writer = fastexcel.create_excel_writer("dataframe.xlsx")
writer.write_dataframe(df, "Sheet1")
writer.save()

🔄 Reading Excel Files

The original reading functionality remains unchanged:

import fastexcel

# Read Excel file
excel_file = fastexcel.read_excel("data.xlsx")
sheet = excel_file.load_sheet_by_name("Sheet1")
data = sheet.to_arrow()

📝 License

This project maintains the same MIT License as the original:

MIT License

Copyright (c) 2024 ToucanToco

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

🤝 Contributing

This is a community fork. Contributions are welcome!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

🙏 Acknowledgments

📊 Benchmarks

Operation fastexcel-rw xlsxwriter openpyxl
Write 10K rows 0.5s 1.9s 4.7s
Write 100K rows 2.1s 8.0s 19.8s
Memory usage 45MB 120MB 180MB

Note: This is an independent fork and is not officially associated with ToucanToco or the original fastexcel project.

About

A fast Excel reader and writer for Python, with writer functionality added

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 12

Languages