> For the complete documentation index, see [llms.txt](https://time-series-features.gitbook.io/pyspi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://time-series-features.gitbook.io/pyspi/information-about-pyspi/api-reference/pyspi.utils.filter_spis.md).

# pyspi.utils.filter\_spis

## <mark style="color:purple;">**filter\_spis**</mark>(*keywords:* [*list*](https://docs.python.org/3/library/stdtypes.html#list)*,* *output\_name:* [*str*](https://docs.python.org/3/library/stdtypes.html#str) *= None*, *configfile:* [*str*](https://docs.python.org/3/library/stdtypes.html#str) *= None*)

Filter a *pyspi* config YAML file using a list of keywords and return a new YAML file containing the reduced set of SPIs in the current working directory.

## Example

```python
from pyspi.utils import filter_spis

# using a user-specified source config file
filter_spis(["linear"], "linear_spis", "./myconfig.yaml")

# using the default config file in the pyspi dir
filter_spis(["linear"], "linear_spis")

# using a randomly generated name and default config file
filter_spis(["linear"]")
```

## Parameters:

| Parameter     | Type                                                                     | Description                                                                                                                                         |
| ------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `keywords`    | [*list*](https://docs.python.org/3/library/stdtypes.html#list)           | List of keywords used to filter SPIs e.g., linear, nonlinear, signed.                                                                               |
| `output_name` | [*str*](https://docs.python.org/3/library/stdtypes.html#str)*, optional* | Name of the filtered YAML file to be saved in the current working directory. If no name is provided, a randomly generated name will be used.        |
| `configfile`  | [*str*](https://docs.python.org/3/library/stdtypes.html#str)*, optional* | Location of the source config file from which to filter SPIs. If no source file is provided, the config.yaml in the *pyspi* directory will be used. |

## Returns

`Nothing` - A new file is created in the current working directory.

## Raises:

* **ValueError**: Raised in three scenarios:
  * If the `keywords` parameter is not a list.
  * If any of the provided keywords is not a string.
  * If no SPIs match the specified keywords.
* **FileNotFoundError**: Triggered if the specified `configfile` cannot be found or if the default `config.yaml` is not present in the expected directory.
* **OError**: Occurs if there's an error reading the specified YAML file.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://time-series-features.gitbook.io/pyspi/information-about-pyspi/api-reference/pyspi.utils.filter_spis.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
