Jump to content

Fuzzy, self-updating list filter workflow template


dfay

Recommended Posts

# fuzzylist
Fuzzy, self-updating list filter workflow for Alfred 3

This is a workflow template - it does nothing as is.

 

## Usage:
- create a csv file like you would for an Alfred List Filter, with an optional fourth field containing the path to an icon file for that result.
- name the file *list.csv* and add it to the workflow directory

On the initial run, the workflow will create a file list.json for output to the fuzzy search.  If list.csv is modified, it will update list.json .  

 

## Credits
- uses fuzzy.py by @deanishehttps://github.com/deanishe/alfred-fuzzy

 

## Download

 

workflow at https://github.com/derickfay/fuzzylist/blob/master/Fuzzy List Filter.alfredworkflow

Edited by dfay
Link to comment
  • 2 years later...

This has been really helpful for me with a workflow I've been running several times a day for a couple years. Thank you!

 

I duplicated the entire workflow for an another application, but how I would go about having multiple lists within the single workflow, each with their own their own trigger? I understand list.json is generated from list.csv, so I imagine the solution would be creating another json from a different csv, but I dont know anything about python.

 

Any help would be appreciated :)

Link to comment
19 hours ago, evanfuchs said:

how I would go about having multiple lists within the single workflow, each with their own their own trigger?

 

I know this can be done by iterating through multiple csv files in the original script, but I don't know how to do that. Trying to help myself and anyone who might stumble across this, this works:

 

  • Add another csv file (list2.csv) to the workflow directory
  • Duplicate fuzzylist.py (fuzzylist2.py), and change the following line:
  • Change theFile="list.csv" to theFile="list2.csv"
  • Duplicate the Script Filter Object and change the reference to fuzzylist.py to fuzzylist2.py in its script.
Link to comment
4 hours ago, evanfuchs said:
  • Duplicate fuzzylist.py (fuzzylist2.py), and change the following line:
  • Change theFile="list.csv" to theFile="list2.csv"
  • Duplicate the Script Filter Object and change the reference to fuzzylist.py to fuzzylist2.py in its script.

 

A more sensible approach would be to change fuzzylist.py to accept a filename as an argument and use the same script for every Script Filter.

Basically, theFile = sys.argv[1]

Edited by deanishe
Link to comment
48 minutes ago, deanishe said:

A more sensible approach would be to change fuzzylist.py to accept a filename as an argument and use the same script for every Script Filter.

Basically, theFile = sys.argv[1]

 

That makes sense. When I change theFile = "list.csv" to theFile = sys.argv[1]  I get an error NameError: name 'sys' is not defined whenever I try to provide any argument.

 

As I said, I don't know what I am doing but I am trying :)

 

 

 

Link to comment
34 minutes ago, dfay said:

You just need to move that line down to below import sys 

 

Thanks @dfay - I did try that, and I get another error. I cant post this as code so here is a screenshot of the debugger.

 

image.thumb.png.1dd8a71a7eccafa41b147784c5f5131a.png

 

I am running the the script filter with a space followed by the file name like this: Fuzzy List Filter list.csv

 

Is that correct?

 

 

Link to comment

Here's what your log should show:

 

1384074606_ScreenShot2020-12-04at12_04_54AM.thumb.png.dc201778c6fa02b030acdf8462ae3d7e.png

 

It looks like you're passing the file name as the query - is that what you're trying to do?  I had thought you were adding separate files but not using the workflow to select among them.  

Here's what my script filters look like:

 

Screen Shot 2020-12-03 at 11.57.42 PM.png

I've added several with unique keywords for each and different csv files in the command above.

 

Edited by dfay
Link to comment
5 hours ago, dfay said:

Here's what my script filters look like

 

That's perfect. Thank you. I didn't know that's how you pass the argument 😬

 

I had also tried changing the script filter to "with input as query" and passing the file name in the Alfred window, but I got an error either way. This was super helpful.

 

Thanks

Link to comment
  • 5 months later...
  • 2 weeks later...
7 hours ago, jhinden said:

Hi there, is it possible to get the search working for Title and Subtile etc.?

 

Yes, but you would need to edit the script so it generates different JSON. Specifically, adding a match field to each JSON item that contains both its title and subtitle should get you filtering across both fields.

 

Link to comment
  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...