This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
can pythonista use pickles?
@bobsmith76 Or, rename your .pkl as .py on your Mac, then import it via iCloud and rename it back as .pkl when it has been imported on "this iPod"
bobsmith76 last edited by bobsmith76
I was not able to rename the file but I created a new file and cut and paste the text of z_dict_words.py into the newly created z_dict_words.pkl. I then ran the code and pythonista was not able to load the pickle file. This is the error message I got:
File "/private/var/mobile/Containers/Shared/AppGroup/D4D2C25F-316F-47DF-8CFF-84E670A3283D/Pythonista3/Documents/main_loop.py", line 163, in get_result
dictionary = pickle.load(pkl_file)
_pickle.UnpicklingError: invalid load key, '\xc2'.
These lines are 150 - 163 in my code:
def get_result(one_sent, user = "", print_type="40", order=, get_words_used=0): global words_used total_time = time.time() if one_sent == 'a': proof_type, print_type, get_words_used, order = parameters() pkl_file = open(user + 'zz_claims.pkl', 'rb') test_sent = pickle.load(pkl_file) pkl_file.close() elif one_sent != "": test_sent = one_sent else: pkl_file = open(user + 'zz_claims.pkl', 'rb') test_sent = pickle.load(pkl_file) pkl_file.close() pkl_file = open(user + 'z_dict_words.pkl', 'rb') dictionary = pickle.load(pkl_file) pkl_file.close()
I'm attaching a screenshot so as to demonstrate that the file is in my script library
@bobsmith76 Sorry but I can't help you:I don't know pickle.
Hoping somebody will help you
what about json? can pythonista handle json?
JonB last edited by
@bobsmith76 pickles are not text, they are binary. copy/paste from a text file wont work.
json and yaml are good alternatives.
or, just use file import of a zipped pkl.
or, post the file in a gist, or on github, and use stash git or wget to retrieve.
If I import a zipped pkl do I have to unzip it? If so how?
cvp last edited by cvp
@bobsmith76 Tap on it and then extract archive
it automatically adds the .py extension to all files. so z_dict_words.pkl becomes z_dict_words.pkl.py. how do i rename files?
brumm last edited by
... or PhoneManager > Rename :)
@cvp, Thanks that did it. Problem solved.