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.


    Writing to csv file

    Pythonista
    4
    4
    2097
    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.
    • applepython
      applepython last edited by

      First time with Pythonista here and I cannot for the life of me figure out how I can point my script to a csv file I have saved on my iPhone

      I tried both Pythonista/External Files / test.csv
      and also Pythonista/Script Library/ This iPhone / test.csv

      An excerpt of my code below:

      row = ['a', 'b', 'c']

      with open(''*WHAT IS EASIEST FILE PATH TO PUT HERE WRITE TO A LOCAL CSV.csv 'a') as csvFile:
      writer = csv.writer(csvFile)
      for i in b:
      row = ['a', i, 'c']
      writer.writerow(row)

      My goal is to use Siri shortcut to run Pythonista in which it will modify a csv file on my iPhone.

      Thanks!

      cvp mikael 2 Replies Last reply Reply Quote 0
      • ?
        A Former User last edited by

        With pandas, it should be much easier. But… Maybe in 9102, pythonista will support pandas.

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @applepython last edited by

          @applepython did you check the doc in Pythonista? here

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

            @applepython, just the file name (”myfile.csv”) will create the file in the directory where your script is.

            Or a relative path like ”../../some/other/dir/myfile.csv” works.

            Or, if you have to be absolute, a path starting with os.path.expanduser('~') will let you start from your Pythonista root dir.

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