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’t write file to iPad
-
@cvp IIRC, it needs to be in a folder inside iCloud, rather than in the "root" iCloud, otherwise you won't have write access?
Also, text files can be viewed from within pythonista. Just swipe from left to see folders, and choose your file.
-
@cvp I ran this program, which is designed to create a text file and save it in iCloud Drive, Pythonista3 folder, but I got an error, so I’m still doing something wrong:
import os # Define the file path file_name = "hello_1.txt" folder_name = "Pythonista3" file_path = os.path.expanduser(f"~/Documents/iCloud Drive/{folder_name}/{file_name}") # Create the file and write to it with open(file_path, "w") as f: f.write("Hello Jim") print("File created successfully!")
THE ERROR I GOT:
Traceback (most recent call last): File "/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/Untitled_2.py", line 9, in <module> with open(file_path, "w") as f: FileNotFoundError: [Errno 2] No such file or directory: '/private/var/mobile/Containers/Shared/AppGroup/B42BE5A2-493D-4659-B268-0AB7FAA58A75/Pythonista3/Documents/iCloud Drive/Pythonista3/hello_1.txt'
-
@JonB thanks for your assistance. Still not there yet as I have not yet been successful in getting a program to save a text file to a folder within the iCloud Drive.
-
@JonB said
it needs to be in a folder inside iCloud, rather than in the "root" iCloud, otherwise you won't have write access?
I have a lot of files in Pythonista iCloud root, seen in Files iCloud Drive/Pythonista 3 without passing by a folder
Also, text files can be viewed from within pythonista. Just swipe from left to see folders, and choose your file.
Agree but he wants to see his text files in Files App, not in Pythonista
-
@SpideryArticle No, I mean that you have to create your script in Pythonista iCloud. Try with the script of @JonB , run it and you would see your .txt file in Files app iCloud Drive/Pythonista 3
And if you want to create an iCloud file from a local Pythonista script, do like
file_name = "hello_1.txt" file_path = f"/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/{file_name}" # Create the file and write to it with open(file_path, "w") as f: f.write("Hello Jim") print("File created successfully!")
-
# Assumes that this file is in the Pythonista iCloud Documents folder. from pathlib import Path here = Path(__file__).parent # print(here.resolve()) (here / "hello_icloud.txt").write_text("On iCloud!")
It would be a nice feature if @omz could build us an symlink between
Path(".") / "iCloud"
and that cryptic path so scripts in the usual directory could read from and write to iCloud. -
@ccc we can always use editor.get_path() for a script existing in Pythonista iCloud.
-
-
@SpideryArticle 👍and welcome here.
-
we can always use
editor.get_path()
for a script existing in Pythonista iCloud.Yes.
editor.get_path()
returns the same string as Python's builtin__file__
but that does not enable scripts in the usual default directory to read from and write to iCloud. -
i never used any ipad i am using laptop