Skip to content

How to order sheets alphabetically using pyexcel? Is this the best way to do so? #125

Description

@simkimsia

Hi there,

I am writing a guide to document some of the more common commands I use with pyexcel.

For ordering sheets alphabetically I wrote this using some clues from documentation:

def order_sheets_alphabetically(
    file_path,
    dest_file_path,
    reverse=False
):
    book = pyexcel.get_book(file_name=file_path)
    sheet_names = book.sheet_names()
    sheet_names.sort(reverse=reverse)
    data = OrderedDict()
    for sheet_name in sheet_names:
        data.update({sheet_name: book[sheet_name]})
    return pyexcel.save_book_as(
        bookdict=data, dest_file_name=dest_file_path)

Is this the best way of doing so?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions