New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
simkimsia opened this Issue Mar 20, 2018 · 6 comments

Comments

Projects
None yet
2 participants
@simkimsia

simkimsia commented Mar 20, 2018

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?

@chfw

This comment has been minimized.

Member

chfw commented Mar 21, 2018

I think I could supply an additional method on Book to sort the sheet names. After that, you could book.save_as(dest_file_path).

@chfw chfw added the enhancement label Mar 21, 2018

@simkimsia

This comment has been minimized.

simkimsia commented Mar 21, 2018

Thanks. I presume my code is valid then. Will leave this ticket opened since you labelled it as enhancement.

@chfw

This comment has been minimized.

Member

chfw commented Mar 23, 2018

def order_sheets_alphabetically(
    file_path,
    dest_file_path,
    reverse=False
):
    book = pyexcel.get_book(file_name=file_path)
    book.sort_sheets(reverse=reverse)
    book.save_as(dest_file_path)

it is in master branch for now.

@chfw

This comment has been minimized.

Member

chfw commented Mar 23, 2018

pip install https://github.com/pyexcel/pyexcel/archive/master.zip will get the version for your trial.

chfw added a commit that referenced this issue Mar 26, 2018

@simkimsia

This comment has been minimized.

simkimsia commented Mar 29, 2018

oh thank you!

will try this out and let you know

@simkimsia

This comment has been minimized.

simkimsia commented Mar 29, 2018

okay

0.5.8 passed
0.6.0 apparently not installable via pip install -r requirements.txt

image

the master branch is okay.

Thank you

@simkimsia simkimsia closed this Mar 29, 2018

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