Created
January 24, 2021 11:46
-
-
Save pdavidsonFIA/1b3d5a6140508c1ff06c0a0b1f60543c to your computer and use it in GitHub Desktop.
Context menu unpickle to excel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def unpickle_to_excel(filenames, params): | |
import os | |
import pandas as pd | |
filename_pkl= os.path.splitext(filenames[0])[0] + '.pkl' | |
filename_xl=os.path.splitext(filenames[0])[0] + '.xlsx' | |
df = pd.read_pickle(filename_pkl) | |
df.reset_index().to_excel(filename_xl, index=False) | |
if __name__ == '__main__': | |
from context_menu import menus | |
cm = menus.FastCommand('unpickle', type='.pkl', python=unpickle_to_excel) | |
cm.compile() | |
#To remove the menu: | |
# from context_menu import menus | |
# menus.removeMenu('unpickle','.pkl') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment