Skip to main content

No project description provided

Project description

EasyPyXL

This python package is a wrapper of OpenPyXL for easy usage.

You can easily write your data on an Excel(.xlsx) file.

It is especially helpful when used in loops.

Stop wasting your energy by printing your experiment results to a text file and copy-pasting them to an Excel file one by one. Instead, use this package.

I tried to handle possible errors, but if you face one, please report it to Github Issues.

Install

Install this package:

pip install easypyxl

If it does not work, try:

pip install git+https://github.com/CauchyComplete/EasyPyXL

Example 1 : Basics

import easypyxl
workbook = easypyxl.Workbook("my_excel.xlsx")  # Excel file to write on. If the file does not exist, it will be created.
cursor = workbook.new_cursor("MySheet", "A2", 5)  # New cursor at sheet "MySheet", starting from "A2", new line every 5 writes.
for i in range(25):
    cursor.write_cell(i)

ex1

Example 2 : write_cell(list)

import easypyxl
workbook = easypyxl.Workbook("my_excel.xlsx", verbose=False)  # Use verbose=False if you want this package to print only important messages. 
cursor = workbook.new_cursor("MySheet", (2, 4), 4)  # You can use (2, 4) in place of "D2".
cursor.write_cell(["Method", "metric1", "metric2", "metric3"]) # You can pass list or tuple for multiple writes.
count = 0
for method in ['A', 'B', 'C', 'D', 'E', 'F']:
    cursor.write_cell(method)
    # Run your code
    for i in range(3):
        cursor.write_cell(count)
        count += 1

ex2

Example 3 : move_vertical

import easypyxl
workbook = easypyxl.Workbook("my_excel.xlsx")
cursor = workbook.new_cursor("MySheet", "B1", 5, move_vertical=True)  # move_vertical: Write top to bottom, then move to the next column.
for i in range(25):
    cursor.write_cell(i)

ex3

Example 4 : Multiple cursors, skip_cell()

import easypyxl
workbook = easypyxl.Workbook("my_excel.xlsx")
cursor1 = workbook.new_cursor("Sheet2", "B2", 4)
cursor2 = workbook.new_cursor("Sheet2", "H2", 4, move_vertical=True)
for i in range(100):
    cursor1.write_cell(i)
    cursor2.write_cell(i * 10)
    if i % 5 == 0:
        cursor1.skip_cell(2)  # Skip two cells

ex4

Example 5 : read_cell(), read_line()

import easypyxl
workbook = easypyxl.Workbook("my_excel.xlsx", backup=False)
cursor = workbook.new_cursor("Sheet2", "B3", 4, reader=True)
print(cursor.read_cell(4))
print(cursor.read_line())
print(cursor.read_line(2))
cursor.skip_line(2)
print(cursor.read_cell())

outputs:

[2, 3, 4, 5]
[None, None, 6, 7]
[[8, 9, 10, None], [None, 11, 12, 13]]
20

Example 6: auto_save=False (manual saving for reducing IO calls)

import easypyxl
workbook = easypyxl.Workbook("my_excel.xlsx")
cursor = workbook.new_cursor("MySheet", "C2", 4, auto_save=False)  # Use auto_save=False when you don't want to save excel at every write.
cursor.write_cell(["Method", "metric1", "metric2", "metric3"])
workbook.save_excel()  # You can manually save the workbook by calling save_excel().
# When the cursor is destructed (EX: when the process finished), finally the excel file is saved.

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

easypyxl-0.5.0.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file easypyxl-0.5.0.tar.gz.

File metadata

  • Download URL: easypyxl-0.5.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for easypyxl-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1a35b3884b73e08132a26deece4b15a95a9585b893b98bf245cf5d4b9218e636
MD5 e99fa1a745d67e3a6f3470cccaa3bc46
BLAKE2b-256 2ae7b6ef7751d4f3d63682f236a4fe8a2c8ada88951d31d73af3dd6338f07ee0

See more details on using hashes here.

Supported by

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