Passing data between Pythonista and shortcuts

I was previously using the clipboard to pass data back from a Pythonista script to a Siri shortcut. The feels cumbersome for more complex data sets so I have investigated writing a CSV data file into iCloud in Pythonista and then accessing that csv file using the get file command in shortcuts.

[imagine a list of 20 calendar appointments with each row being a single event with 6 columns per event of date, name, time etc ]

This actually works well with one big issue. Pythonista is only allowed to write to /iCloud/Pythonista and shortcuts is only allowed to read from /iCloud/shortcuts. You can use the file picker as a work around but that defeats the object of it working automatically.

My work around is to have Hazell running on my always on Mac, watching the /iCloud/Pythonista folder and moving any file it finds there to /iCloud/shortcuts so that the file can be opened in shortcuts!

This works but again feels very hacky and means that I have to run a wait delay when Pythonista hands back to shortcuts to allow everything to sync up.

Any one got a better work around or Method?

A much simpler workaround would be to use Dropbox, Shortcuts can save to anywhere in Dropbox and Pythonista has a Dropbox module you can use in your scripts.

2 Likes