Forum Archive

Pythonista on Ipad

Ayzar247

Hello, I am fairly new to python and pythonista.

I have a small problem, when writing a fhand=open() function for .txt file my app gives a traceback error of no such fil exists.
How do i read a txt file in python thats on my Files app locally on my ipad?

Thanks in advance

cvp

@Ayzar247 you have to, once, give Pythonista access to your "on my iPad" folder in Files.
This is done via the open external, then folder, then select "on my iPad".
.

The choose the location

Then you will see this

And in your script, you will have access to a file by a path like

path = '/private/var/mobile/Containers/Shared/AppGroup/EF3F9065-AD98-4DE3-B5DB-21170E88B77F/File Provider Storage/Myfile.txt'

Where the EF3F9065-AD98-4DE3-B5DB-21170E88B77F part will be different for your device.
I still have to remember how to find this value...

Édit: create this script in this folder and run it

import sys
print(sys.argv[0])