omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    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?

    Pythonista
    4
    34
    15462
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bobsmith76
      bobsmith76 last edited by

      Ok, I can do the first 3 steps but when I go and hit edit script, a list of my files will pop up which are available in my icloud and even though my pkl files are in my icloud they do not appear so that I cannot select them. I tried renaming them as dat files but that did not work either.

      cvp 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @bobsmith76 last edited by

        @bobsmith76 After edit script, you have to select the import script that you have just copied some hours ago, and run it

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @bobsmith76 last edited by cvp

          @bobsmith76
          When you have, in Files app, selected your .pkl file, and klicked share at bottom left,
          Do you see this menu? If yes, click "import file" and your .pkl file will be on "this iPod"
          (Forget the script I linked in the begin of this topic)

          1 Reply Last reply Reply Quote 0
          • bobsmith76
            bobsmith76 last edited by

            Maybe I did this step incorrectly

            https://forum.omz-software.com/topic/3606/script-to-import-any-file-in-pythonista-from-any-app

            i named that files python_script and put it in my file folder which contains all of my other files. maybe that was wrong. in any case, when i click on pyth_script.py from 'script library' this ipod touch, i then hit the wrench sign, then share, then run pythonista3, then i see that menu you're telling me about. when i hit edit script, nothing happens, because just take me back to the script library and the pkl files aren't there, when i hit import file, it just copies the pyth_script to my script library.

            cvp 3 Replies Last reply Reply Quote 0
            • cvp
              cvp @bobsmith76 last edited by

              @bobsmith76 Forget this method and try the last one I described with an image

              1 Reply Last reply Reply Quote 0
              • cvp
                cvp @bobsmith76 last edited by cvp

                @bobsmith76 With any method, you have to start the process not in Pythonista but in the Files app showing your .pkl file!
                Then, you have to select the .pkl file and click share at the bottom left...

                cvp 1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @cvp last edited by cvp

                  @cvp print of French screen in Apple Files app

                  1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp @bobsmith76 last edited by

                    @bobsmith76 What you did in your last post is to share your script from Pythonista to Pythonista instead of sharing a .pkl file from another app (ex: Files app) to Pythonista 😇.
                    When an external shared file "arrives' in Pythonista, you have to import it via the standard "import file" (since last version) or via an user script (like your copied script). The import will copy your .pkl file to "script files/this iPod/name.pkl"

                    1 Reply Last reply Reply Quote 0
                    • bobsmith76
                      bobsmith76 last edited by

                      here, I took some screenshots available here

                      https://drive.google.com/drive/folders/1djAgW_weu-eGZFB-ZKV_6ZOQzu6bxXrB?usp=sharing

                      when I click on the file to share on my desktop with is lemmata.pkl nothing relating to pythonista3 shows up.

                      1 Reply Last reply Reply Quote 0
                      • bobsmith76
                        bobsmith76 last edited by

                        hold on, I didn't see that part about using the files app on the ipod.

                        1 Reply Last reply Reply Quote 0
                        • bobsmith76
                          bobsmith76 last edited by

                          i'm trying to download some kind of file manager app ut not having much success because i have an ipod 6 touch which is very old.

                          cvp 2 Replies Last reply Reply Quote 0
                          • cvp
                            cvp @bobsmith76 last edited by cvp

                            @bobsmith76 ok, if you don't have IOS 11, forget the solution from Files App.
                            But I see in your images that the .pkl is already in Pythonista3...
                            Thus, what do you want?

                            I had not seen it was on Mac, sorry
                            If you send the file via mail and when you receive the mail on your iPod, you can make a long press on the attachment,, click share, run Pythonista 3 script and click on standard "import file" on img_0313.png

                            1 Reply Last reply Reply Quote 0
                            • cvp
                              cvp @bobsmith76 last edited by

                              @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"

                              1 Reply Last reply Reply Quote 0
                              • bobsmith76
                                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=[0], 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

                                https://ibb.co/mkgSVS

                                cvp JonB 2 Replies Last reply Reply Quote 0
                                • cvp
                                  cvp @bobsmith76 last edited by

                                  @bobsmith76 Sorry but I can't help you:I don't know pickle.
                                  Hoping somebody will help you

                                  1 Reply Last reply Reply Quote 0
                                  • bobsmith76
                                    bobsmith76 last edited by

                                    what about json? can pythonista handle json?

                                    1 Reply Last reply Reply Quote 0
                                    • JonB
                                      JonB @bobsmith76 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.

                                      1 Reply Last reply Reply Quote 0
                                      • bobsmith76
                                        bobsmith76 last edited by

                                        If I import a zipped pkl do I have to unzip it? If so how?

                                        cvp 1 Reply Last reply Reply Quote 0
                                        • cvp
                                          cvp @bobsmith76 last edited by cvp

                                          @bobsmith76 Tap on it and then extract archive

                                          1 Reply Last reply Reply Quote 0
                                          • bobsmith76
                                            bobsmith76 last edited by

                                            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?

                                            cvp 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors