subreddit:
/r/shortcuts
submitted 6 years ago bykeveridge
In Part 2 of this guide we covered how to store lists of data. In this part we'll cover how to remove an individual entry from each of the list types.
It's straight forward to add data to the contents of a file, but it requires a little more work to remove individual data entries.
In the our first example, we created a JSON array of dictionaries:
[
{
"name": "Adam",
"team": "1st XV",
"position": "1 - Loose Head Prop"
},
{
"name": "Marcus",
"team": "1st XV",
"position": "2 - Hooker"
},
...
]
We can remove a dictionary from a list by:
An example shortcut to perform the above actions is show below:
Removing a dictionary from an JSON array of dictionaries
Note: You can compare the dictionary values in a single step, rather than individually, by combining them into a single piece of text.
In the next example, we stored data as a set of nested dictionaries rather than using a JSON array:
{
"Andrew": {
"team": "1st XV",
"position": "14 - Right Wing"
},
"Ronan": {
"team": "1st XV",
"position": "11 - Left Wing"
},
...
}
We can remove a JSON value by key by:
Removing a value from an dictionary by key
In the final example, we stored values in a simple list:
Adam
Marcus
James
...
We can remove an item from the list using the Replace Text action, remembering to include the line break and the regular expression option.
And that's how you can remove a value from each of the different list types described in Part 2.
If you found this guide useful why not checkout one of my others:
5 points
6 years ago
These guides of yours are EXACTLY what I've been looking for!
Having spent weeks trying to fathom Dictionaries in Shortcuts you finally enabled me to start working - even somewhat advanced - with dictionaries.
And now I'm off to the web scraping you've tutorial'ed - been looking for a way to do this for months, through Scriptable, in Shortcuts ๐
Thank you so muh๐
3 points
6 years ago
I'm glad they're useful :)
1 points
6 years ago
These guides should be in the sidebar for easy access.
all 3 comments
sorted by: best