Skip to main content

Enrich data using datasette and arbitrary commands on your local machine

Project description

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.

datasette install -U datasette-enrichments-shell

Or, if you are hacking on this locally:

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:

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:

cd datasette-enrichments-shell
poetry install

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datasette_enrichments_shell-0.2.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file datasette_enrichments_shell-0.2.0.tar.gz.

File metadata

  • Download URL: datasette_enrichments_shell-0.2.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.4 Linux/6.2.0-1019-azure

File hashes

Hashes for datasette_enrichments_shell-0.2.0.tar.gz
Algorithm Hash digest
SHA256 51858a4d2969ee4c1fba822064779aadf118037e314dd6628ef575cf1edd6c03
MD5 5bd84464e29c6114f6d134149941f81f
BLAKE2b-256 ba73de550084d2a592b03a276a06c43198a14a6ca3d508aa2409296f2a631eb5

See more details on using hashes here.

File details

Details for the file datasette_enrichments_shell-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_enrichments_shell-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2c40a290322d5105d1bf965a7b179d0705479d2407f40e2e5c386306fbdd10d
MD5 055595c666301442252b210e6da68ae2
BLAKE2b-256 42a60307935e919b04c96b2d604a8c9699ad9b540b5a60ec5f604ad473593927

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page