# datasette-enrichments-shell
Something I've always wanted to do is to be able to easily run a map reduce operation on a CSV. This is something that all the nifty command line tools (zq, jq, etc) don't allow you to do.
However, I noticed that Datasette recently added the ability to write enrichment plugins. I hacked together this enrichment plugin that allows you to run an arbitrary shell script and if the script was successful, save the resulting output to a new column.
## Installation
Install this plugin in the same environment as Datasette.
```shell
datasette install -U datasette-enrichments-shell
```
Or, if you are hacking on this locally:
```shell
datasette install -U ~/Projects/python/datasette-enrichments-shell
```
## Usage
After installing the plugin, you'll see the shell enrichment option in the UI. You can use this to run a shell command and save the output to a new column.
### Examples
Here's how to test a shell script before plugging it into the web UI:
```shell
echo '{"rowid": 1, "firstName": "Forest", "lastName": "Tree"}' | \
jq -r '"-p firstName \(.firstName) -p lastName \(.lastName)"' | \
xargs -I {} /Users/mike/.asdf/shims/sqlite-utils query email_personal.db "SELECT * FROM address_book WHERE first_name = :firstName AND last_name = :lastName LIMIT 1" {}
```
## Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd datasette-enrichments-shell
poetry install
```
Raw data
{
"_id": null,
"home_page": "",
"name": "datasette-enrichments-shell",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "datasette,datasette-enrichments,shell,sqlite",
"author": "Michael Bianco",
"author_email": "mike@mikebian.co",
"download_url": "https://files.pythonhosted.org/packages/ba/73/de550084d2a592b03a276a06c43198a14a6ca3d508aa2409296f2a631eb5/datasette_enrichments_shell-0.2.0.tar.gz",
"platform": null,
"description": "# datasette-enrichments-shell\n\nSomething I've always wanted to do is to be able to easily run a map reduce operation on a CSV. This is something that all the nifty command line tools\u00a0(zq, jq, etc) don't allow you to do.\n\nHowever, I noticed that Datasette recently added the ability to write enrichment plugins. I hacked together this enrichment plugin that allows you to run an arbitrary shell script and if the script was successful, save the resulting output to a new column.\n\n## Installation\n\nInstall this plugin in the same environment as Datasette.\n\n```shell\ndatasette install -U datasette-enrichments-shell\n```\n\nOr, if you are hacking on this locally:\n\n```shell\ndatasette install -U ~/Projects/python/datasette-enrichments-shell\n```\n\n## Usage\n\nAfter installing the plugin, you'll see the shell enrichment option in the UI. You can use this to run a shell command and save the output to a new column.\n\n### Examples\n\nHere's how to test a shell script before plugging it into the web UI:\n\n```shell\necho '{\"rowid\": 1, \"firstName\": \"Forest\", \"lastName\": \"Tree\"}' | \\\njq -r '\"-p firstName \\(.firstName) -p lastName \\(.lastName)\"' | \\\nxargs -I {} /Users/mike/.asdf/shims/sqlite-utils query email_personal.db \"SELECT * FROM address_book WHERE first_name = :firstName AND last_name = :lastName LIMIT 1\" {}\n```\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n\n```bash\ncd datasette-enrichments-shell\npoetry install\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Enrich data using datasette and arbitrary commands on your local machine",
"version": "0.2.0",
"project_urls": {
"CI": "https://github.com/iloveitaly/datasette-enrichments-shell/actions",
"Changelog": "https://github.com/iloveitaly/datasette-enrichments-shell/releases",
"Homepage": "https://github.com/iloveitaly/datasette-enrichments-shell",
"Issues": "https://github.com/iloveitaly/datasette-enrichments-shell/issues"
},
"split_keywords": [
"datasette",
"datasette-enrichments",
"shell",
"sqlite"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "42a60307935e919b04c96b2d604a8c9699ad9b540b5a60ec5f604ad473593927",
"md5": "055595c666301442252b210e6da68ae2",
"sha256": "f2c40a290322d5105d1bf965a7b179d0705479d2407f40e2e5c386306fbdd10d"
},
"downloads": -1,
"filename": "datasette_enrichments_shell-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "055595c666301442252b210e6da68ae2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 5735,
"upload_time": "2024-02-23T14:34:40",
"upload_time_iso_8601": "2024-02-23T14:34:40.249684Z",
"url": "https://files.pythonhosted.org/packages/42/a6/0307935e919b04c96b2d604a8c9699ad9b540b5a60ec5f604ad473593927/datasette_enrichments_shell-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ba73de550084d2a592b03a276a06c43198a14a6ca3d508aa2409296f2a631eb5",
"md5": "5bd84464e29c6114f6d134149941f81f",
"sha256": "51858a4d2969ee4c1fba822064779aadf118037e314dd6628ef575cf1edd6c03"
},
"downloads": -1,
"filename": "datasette_enrichments_shell-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "5bd84464e29c6114f6d134149941f81f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 4583,
"upload_time": "2024-02-23T14:34:42",
"upload_time_iso_8601": "2024-02-23T14:34:42.049588Z",
"url": "https://files.pythonhosted.org/packages/ba/73/de550084d2a592b03a276a06c43198a14a6ca3d508aa2409296f2a631eb5/datasette_enrichments_shell-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-23 14:34:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "iloveitaly",
"github_project": "datasette-enrichments-shell",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "datasette-enrichments-shell"
}