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.


    Create .txt in a FTP folder?

    Pythonista
    2
    3
    2026
    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.
    • philg
      philg last edited by

      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:

      1. Create a blank .txt file (in a FTP folder, that's the important part)
      2. 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?

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

        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)

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

          It does.

          Thank you for Shellista. And for confirming that my local file is being deleted.

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