Skip to content

Instantly share code, notes, and snippets.

@pdavidsonFIA
Created January 24, 2021 11:46
Show Gist options
  • Save pdavidsonFIA/1b3d5a6140508c1ff06c0a0b1f60543c to your computer and use it in GitHub Desktop.
Save pdavidsonFIA/1b3d5a6140508c1ff06c0a0b1f60543c to your computer and use it in GitHub Desktop.
Context menu unpickle to excel
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