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.


    Accessing files in IOS Files App

    Pythonista
    4
    5
    2029
    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.
    • cnaeger
      cnaeger last edited by

      I am having trouble accessing files located in the IOS Files app. I have read many of the threads but must be missing something.

      Example:

      I went to the External Files section and added the top level folder that contained both a txt file, images and videos.

      The top level folder is called ‘myFiles’.

      Once added I assumed I would be able to open the file ‘email.txt’ as one of the following:

      fh = open(‘email.txt’). Ie. It would used myFiles directory as part of a search path. Or

      fh = open(‘myFiles/email.txt’) and also tried fh = open(‘/myFiles/email.txt’)

      Thanks,
      Chad

      stephen mikael 2 Replies Last reply Reply Quote 0
      • akempkens
        akempkens last edited by

        I think this depends a bit on from where you are starting your script now.

        The external folder is not equal to the site-packages folders that are automatically in your system path. And I figured out that e.g. running a file for doctest purposes and compared to the standard results is totally different path structures. External folders might be outside the Pythonista app folder structure.

        Therefore check

        import sys
        sys.path
        

        To see if the files you are looking for are actually on this path. Best add a simple test python in the same folder.

        1 Reply Last reply Reply Quote 0
        • stephen
          stephen @cnaeger last edited by

          @cnaeger i just tested and im having zeo problemes runing and programmatically opening external files

          1 Reply Last reply Reply Quote 0
          • mikael
            mikael @cnaeger last edited by mikael

            @cnaeger, your .py file needs to be in the same folder for you to be able to open ”email.txt” with no other path info.

            If you want to know what the full path to the file location is, place this script in that location, open and run it there:

            import editor
            print(editor.get_path())
            

            This path you can use to access the files from scripts that are located in e.g. the Pythonista folder structure. Be warned though that Pythonista’s access to the folder can be lost and needs to be re-established, I think at least when installing a beta, maybe even with a regular update.

            stephen 1 Reply Last reply Reply Quote 1
            • stephen
              stephen @mikael last edited by

              @mikael said:

              Be warned though that Pythonista’s access to the folder can be lost and needs to be re-established, I think at least when installing a beta, maybe even with a refular update.

              ive never ran a Beta build of Pythonista but when the App does lose my path i laiunchnin Safe Mode and it gets restored.

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