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.
Create .txt in a FTP folder?
-
Hello. I managed to connect to my ftp and create a new directory with ftp.mkd(folderName). However, I want to create a txt file within this folder and write in it with another string. In quick steps:
- Create a blank .txt file (in a FTP folder, that's the important part)
- Add text to the .txt file.
How it gets done?
MAYBE, I fixed by creating a local file, there we go:
article = 'This is my whole article.'
open('article.txt', 'w').write(article)
ftp.storlines('STOR ' + path/to/folder/article.txt, open('article.txt','r'))
os.remove('article.txt')I believe this generates a local text file in my device, so I thought about using os.remove to delete it afterwards, does it work as I could expect?
-
It all looks right to me. Is it doing all the stuff that you had hoped it would?
I used the indispensable Shellista to verify that: 1) the local file is getting created, 2) has the right content, and 3) is getting properly deleted.
(http://omz-software.com/pythonista/forums/discussion/74/advanced-shell-shellista) -
It does.
Thank you for Shellista. And for confirming that my local file is being deleted.