Skip to content

Instantly share code, notes, and snippets.

@achim
Last active August 29, 2015 14:24
Show Gist options
  • Save achim/4e346cf4932d5c0e7dfc to your computer and use it in GitHub Desktop.
Save achim/4e346cf4932d5c0e7dfc to your computer and use it in GitHub Desktop.
Display pickled pandas dataframes
#! /usr/bin/env python
from __future__ import print_function
import webbrowser
import cPickle as pickle
import tempfile
import argparse
def main():
parser = argparse.ArgumentParser(description='Display .df.pickle files')
parser.add_argument('file', help='path to the file to display')
args = parser.parse_args()
with tempfile.NamedTemporaryFile(suffix='.html', delete=False) as fout:
with open(args.file, 'r') as fin:
df = pickle.load(fin)
print(df.to_html(), file=fout)
print(fout.name)
webbrowser.open('file://' + fout.name)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment