Apple Wallet to CSV

Hi,

I’m running into a snag trying to setup a personal automation that does the following:

  1. When I tap on Wallet passes or payment card
  2. Do Receive transaction as input (from Wallet)
  3. Into Dictionary with Keys Merchant, Name, Amount, Card
  4. Look up Merchant against a list of names in one of three lists (Fixed, Needs, or Wants)
  5. If found in one of the lists, set variable Type to list name (Fixed, Needs, or Wants)
  6. Get Current Date (set format to ISO 8601)
  7. Combine in Text as Date,Merchant,$Amount,Type
  8. Append Text to Folder; File Path: P+L_Tracker.csv; Make New Line checked

Here’s the issue, I can get #1, #2 and #3 to work, when done in the Automation under the When and Do; but I don’t want to do #2#8 done in the Automation; but via a Shortcut. What I cannot figure is, how to run the shortcut to accept into the Dictionary in the Shortcut, the Input from the Automation, as I need to specify the Dictionary Key’s Value based on the Automation Input that’s not visible to the Shortcut, if that makes sense (or do I just need to set the Variable to the Dictionary in the Automation Do part, and call it from inside the separate Shortcut, via a get Variable?
Other than that, the Lists are for Fixed, Needs, or Wants that break down to:
Fixed - Mortgage, Rent, Auto Insurance, Hydro…
Needs - Groceries, Medication, etc.
Wants - Cafe, Restaurant, Clothing, Books…

And how to I look those up; I was planning to use an If statement; but that’s not going to do it (I think). What I was thinking was:

Check If

  1. Merchant is in List Fixed set variable to Fixed; else
  2. Merchant is in List Needs set variable to Needs; else
  3. Merchant is in List Wants set variable to Wants; else
  4. Otherwise Nothing

Set Variable Type from above nested If statement

At this point combine into #7 earlier:
7. Combine in Text as Date,Merchant,$Amount,Type

I’ve worked parts of this up in various separate scripts; but the noted issues are what drive me batty. Any help would be appreciated and I’ll provide snippets of my work, as I can get them.

Rough of what I have:

Here’s the link to the Shortcut sofar:

Purchase_Tracker

Thanks in advance for any ideas.

BlackMacX

Yes (or use the magic variable so you don’t have to assign a separate variable name) and then use the Run Shortcut action to call your Shortcut; tap on the arrow and you can select the input for the Shortcut. The display of the action seems a bit broken in the latest iOS as it doesn’t show the selected input until you tap at the right of the input message.

…and then in your Shortcut, do the following:

to get the dictionary from the Shortcut input.

Hope this helps.

Thank you Tony for the pointers.

I have revised things and though it sorta works now, in a way, the Automation is only kicking off the process and the Dictionary therein is not capturing the data nor passing it along. As such and looking at other Automations, I have done the following:

Note: I think the TransID key pulling the Transaction value, will be unneeded.

From here, I have also updated the Shortcut (link below) and am hoping this will work. I included the testoutput.csv file, to make sure that when the automation runs, I can see (looking back) if the input is properly captured. If so, I suspect the issue then will be the Shortcut and how it is setup.

Here’s the updated Shortcut’s link: Shortcuts

Again thank you in advance.

I have it setup now that the Automation passed all the data through, except the Amount data isn’t coming through. I have tested is by changing the Type from Number to Text and neither is bringing the data through; though the value was successfully being pasted from the Automation to a csv file in either case. On the Shortcut side, I have made sure the Amount Dictionary Key is set to the same as the Automation Dictionary Key was set at the same time and still no luck. Any ideas?

Again, here’s the link to my updated Shortcut:

Purchase_Tracker.shortcut

The Red text reads "This is setup as Text Type presently. I have also used Number Type previously, one I knew the rest of the data was getting through. Still no luck.

An update for anyone interested in this Shortcut; I have restored the Dictionary data being passed from the Personal Automation to the Shortcut, with the Merchant and Date detail making it through; but the Amount data is still showing as 0. I was able to have the Automation print the details to a text file and it showed the Amount data was fine at that point. I have removed that function from the Automation; but now have added it into the Shortcut, immediately between the Set Variable action and the Dictionary; the function is two actions, the first a Text action that gets the TransActionDictionary value and pastes it into the text field, the second then saves this to a new file called Purchase_Tracker.txt. This way, it will be pasted into that text file, and I can see if the Amount data is at least, carried over from the Personal Automation. If it is, I know it is in either the Dictionary Key/Type/Value for the Amount data that there’s something wrong or in the further down Text action that is used to pasted the various Variables and such, into the final Purchase_Tracker.csv file.

If anyone reading this has suggestions/insight, I would appreciate it.

Cheers,

BlackMacX

In the Shortcut, try using the Get Dictionary Value action to get the data from the dictionary passed from the automation:

Updated Shortcut

Hope this helps.

Hi Tony,

I have done that and all the data, except the actual Amount value, comes through. The Merchant is passed correctly; but the Amount value comes through as $0. As per the attached, you can see that the Dictionary in the Automation, has the Amount Key with the Value set as noted. It appears to be correct and should be passing through; but isn’t. I have tried to different “Add new item” types, Text and Number; both fail to pass through any dollar value, except 0. I do have a part of the automation that prints the Dictionary values to a Text action, then saves it to a Text file. That works; but I want most of the work to be in a Shortcut, so that it can be save outside Shortcuts when I do a weekly backup, incase I have to rebuild or share the shortcut with family.

Or should I give up that idea and just put it all into the Automation? But then, it is device specific, which defeats the idea I had in the first place.

I gratefully appreciate any suggestions/help.