2

In Matlab, I can drag-and-drop a .mat key-value-pair data file into the Matlab window and it will populate the Workspace of variables.

Is there a way to do the same thing in Python world, namely drag-and-drop .pkl files into PyCharm?

I can see from this question that I can use shelve rather than pickle for this goal. Then any ideas on how to make this more drag-and-drop-y in context of PyCharm IDE?

Lars Ericson
  • 1,952
  • 4
  • 32
  • 45

1 Answers1

4

PyCharm doesn't do that. Meantime, you can read a .pkl file by using code in a pretty simple way. The following approach uses pickle library.

Example

import pickle

# read python dict back from the file
pkl_file = open('myfile.pkl', 'rb')
mydict2 = pickle.load(pkl_file)
pkl_file.close()

print mydict2

Reference:

https://www.saltycrane.com/blog/2008/01/saving-python-dict-to-file-using-pickle/

afjm
  • 169
  • 12
  • That gives me a dictionary called mydict2, how do I load the elements of that dictionary into the current environment, i.e. if mydict2={'a':12}, how do I get the same effect as typing a=12 into the interpreter? – Lars Ericson Jan 10 '18 at 17:40
  • 1
    Actually that is answered [here](https://stackoverflow.com/questions/2960864/how-can-i-save-all-the-variables-in-the-current-python-session). – Lars Ericson Jan 10 '18 at 20:13
  • 1
    I will close this as answered because nobody is claiming that PyCharm can be fiddled with to get it to do drag and drop of [shelves](https://docs.python.org/2/library/shelve.html) or pickles. So I'll take that as a No, by default judgment. – Lars Ericson Jan 12 '18 at 16:05