Shortcut “choose from list”

This might be a simple o e, but I can’t figure it out.

I have items I want to choose from a list. If the item is selected, assign 1 otherwise 0. Then, the easy bit, creates a csv—like text

The thing is that if I use “choose from list”, only items checked are considered for the next step.

example:

Item 1 :heavy_check_mark:
Item 2
Item 3
Item 4 :heavy_check_mark:
Item 5 :heavy_check_mark:

Should return: 1; 0; 0; 1; 1

What basic thing am I missing here?

Thanks!!

Hmmm, this isn’t how the list works really. I’ve put together a shortcut showing how you could do this though: https://www.icloud.com/shortcuts/bbd4c2adcca34320952a331c68117d5e

1 Like

Thanks!!

“Combine text”, that’s the bit I was missing :man_facepalming:

Is there a better way of achieving the same result? (I want to be able to choose all items at once, as opposed to be asked for each one individually).

Thank you!!

I think the point is that you wouldn’t normally choose to switch named list entries, the result of a multi-select list, to an ordered set of binary digits. In typical circumstances, the former would probably be considerably easier to work with than the latter.

Perhaps you could share some details of why you want to convert to this particular format? Are you maybe aggregating data for a flat file?

That’s right. It’s an idea I’m playing around with.

Say I have a list of activities that I do on weekdays. At the end of each day I mark those that got completed (ie “1”) and get a string with date plus 1’s and 0’s (e.g. 10/6/2019;1;0;1;1;1). This string gets written to a file and at the end of each month I can do some analysis.

I could do this straight into a spreadsheet, but that would require me to open the file, type in, save, etc. With a shortcut it saves so much time every day.

Note: the idea is not to track time but only whether it’s been done or not.

I suggest you to use a dictionary (= JSON) instead of a csv file, as that saves you some parsing.

I’ve made a quick example of how I would do it: https://www.icloud.com/shortcuts/0e3fe5556a8e4ae6b0391ae81ed62aed

I’ve commented it to explain every thing why I’ve done it that way.

I hope it helps you to achieve your goal :wink:

What you want to do at the end is something to keep in mind.

For example, flat files such as the one you created above, or JSON as suggested by @schl3ck don’t really tend lend themselves to basic numeric analysis. Certainly not as much as having it in a spreadsheet might seeing as you mentioned that without prompting.

The assertion that you have to open a spreadsheet app to insert into a spreadsheet file for example is not necessarily so.

Shortcuts could for example trigger an IFTTT web hook, passing in data to be used to auto populate the next available row in a Google spreadsheet. That then gives you access to all of the analytics options in Google Sheets.

Shortcuts could also write the data directly to an Airtable table and you can similarly query the data through database queries that could aggregate and analyse the data in practically any way you might imagine.

End of the day, find the most efficient way to get you to your destination. Sometimes it’s the scenic route around the mountain. Sometimes it’s the quicker but more daring route over it. And sometimes, you might just find that it is possible, with a bit of lateral thinking and effort, to go though :wink:

1 Like

Yes, they don’t offer as much data analysis as a spreadsheet, but if you structure them right (not like in my example), then in this case the wanted analysis is possible pretty easily. I currently think of not storing a JSON dictionary for each day, but extending the lists of each task. Think like a list of the columns from the file format:

Something like this:

{
    "task 1": [0,0,1,1,0,1,0,1,1,1],
    "task 2": [0,0,1,1,1,1,0,0,1,1],
    "task 3": [1,0,0,1,0,1,0,1,1,0]
}

If you want to also save the days, just add another key with an array of the days. Then you can just use the action Calculate Statistics on the list/array.

1.We don’t actually know what analysis is to be be done ultimately.
2. I would still stand by my earlier statements and as such I would rather do numerical analysis in a spreadsheet rather than by processing a JSON file. I never indicated things couldn’t be done, only that there might be better options that had previously been discounted.

1 Like

Thanks @schl3ck and thanks @sylumer for your thoughts!

Thanks for this. Using a dictionary is a good idea. It might just be a bit overhead for what I need (having said that you just helped me with another project I have in my to-do list :smiley: ). I’d prefer to have it in a spreadsheet because it allows me to do some numerical analysis but also build some graphs at the end of each month.

This is ultimately where I want to get to.

I’d like to quickly select from a “pre-defined” list on a daily basis (and @RosemaryOrchard’s Shortcut does this with few tweaks, e.g. adding the short date at the beginning of each line) and then add it into a google sheet.

The csv file was a middle step and I can also open it with a spreadsheet. I don’t fully trust IFTTT (I had a couple of bad experiences in the past) thus have not jumped into it immediately.

:man_facepalming: totally forgot about this option :grinning: trying it now. After running Rosemary’s shortcut I could save the results in Airtable. Somehow I associate Airtable with more complex database needs and forget that I can also do simple things with it :grinning:

Thanks both!

I know I’m a complete dinosaur , but something else to think about here is if you really want to rely on the internet existing for this? I’ve been in far too many situations where it didn’t, and with something like a habit tracker which this looks like it might be worth thinking about.

I’d probably create a Shortcut that appended to a csv file, and another one that uploaded that file to Airtable or Google sheets then deleted the CSV file.

Thanks for this thread, BTW. It’s given me some ideas for a project of my own that’s been in the back of my brain for a while, :slight_smile:.

Thanks @Yvonnezed. You’re right, these will be primarily for a habit tracker (though I’ll also apply the concept o other projects I have)

Part of the reason I’m not keen on the IFTT solution is exactly that dependency on the Internet + a webservice.

The csv solution only is not great because that means I’ll have to re-create formulas everytime I open it in a spreadsheeet. Though basic these will be basic, I don’t want to repeat them.

That why I like the Airtable approach. Though you need Internet to send your data (which I’ll have 99.99999% of the time in this particular use case), it allows me to keep formulae in AND access data even when I’m offline.

Good luck for your projects!

I see what you mean. What’d be nice is if something like Numbers had proper Shortcuts support. Add row to Numbers sheet would be nice.

Maybe as a compromise save a csv to the shortcuts folder just before you write to Airtable just to make sure you don’t lose any data in case it fails? You could just overwrite it each time.

1 Like

This would be a dream come true! :grinning: