2022-03-25 11:13:59 +01:00
|
|
|
# orcli (💎+🤖)
|
|
|
|
|
|
|
|
Bash script to control OpenRefine via [its HTTP API](https://docs.openrefine.org/technical-reference/openrefine-api).
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
* works with latest OpenRefine version (currently 3.5)
|
2022-04-20 10:08:05 +02:00
|
|
|
* batch processing (import, transform, export)
|
|
|
|
* orcli takes care of starting and stopping OpenRefine with temporary workspaces
|
|
|
|
* your existing OpenRefine data will not be touched
|
2022-04-04 23:03:20 +02:00
|
|
|
* import CSV, ~~TSV, line-based TXT, fixed-width TXT, JSON or XML~~ (and specify input options)
|
2022-04-20 10:08:05 +02:00
|
|
|
* supports stdin, multiple files and URLs
|
|
|
|
* transform data by providing an [undo/redo](https://docs.openrefine.org/manual/running#history-undoredo) JSON file
|
|
|
|
* orcli calls specific endpoints for each operation to provide improved error handling and logging
|
|
|
|
* supports stdin, multiple files and URLs
|
2022-04-04 23:03:20 +02:00
|
|
|
* export to TSV, ~~CSV, HTML, XLS, XLSX, ODS~~
|
2022-04-04 23:00:37 +02:00
|
|
|
* ~~[templating export](https://docs.openrefine.org/manual/exporting#templating-exporter) to additional formats like JSON or XML~~
|
2022-03-25 11:13:59 +01:00
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
2022-04-20 10:08:05 +02:00
|
|
|
* GNU/Linux with Bash 4+
|
|
|
|
* [jq](https://stedolan.github.io/jq)
|
|
|
|
* [curl](https://curl.se)
|
|
|
|
* [OpenRefine](https://openrefine.org) 😉
|
2022-03-25 11:13:59 +01:00
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
1. Navigate to the OpenRefine program directory
|
|
|
|
|
|
|
|
2. Download bash script there and make it executable
|
|
|
|
|
|
|
|
```sh
|
|
|
|
wget https://github.com/opencultureconsulting/orcli/raw/main/orcli
|
|
|
|
chmod +x orcli
|
|
|
|
```
|
|
|
|
|
|
|
|
3. Create a symlink in your $PATH (e.g. to ~/.local/bin)
|
|
|
|
|
|
|
|
```sh
|
|
|
|
ln -s "${PWD}/orcli" ~/.local/bin/
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Ensure you have OpenRefine running (i.e. available at http://localhost:3333 or another URL) or use the integrated start command first.
|
|
|
|
|
|
|
|
Use integrated help screens for available options and examples for each command.
|
|
|
|
|
|
|
|
```sh
|
2022-04-04 23:00:37 +02:00
|
|
|
$ orcli --help
|
2022-03-25 11:13:59 +01:00
|
|
|
orcli - OpenRefine command-line interface written in Bash
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
orcli [command]
|
|
|
|
orcli [command] --help | -h
|
|
|
|
orcli --version | -v
|
|
|
|
|
|
|
|
Commands:
|
2022-04-20 12:27:53 +02:00
|
|
|
batch start tmp OpenRefine workspace and run multiple orcli commands
|
2022-04-14 00:04:35 +02:00
|
|
|
import import commands
|
|
|
|
list list projects on OpenRefine server
|
2022-04-20 12:27:53 +02:00
|
|
|
info show project metadata
|
|
|
|
export export commands
|
2022-03-25 11:13:59 +01:00
|
|
|
|
|
|
|
Options:
|
|
|
|
--help, -h
|
|
|
|
Show this help
|
|
|
|
|
|
|
|
--version, -v
|
|
|
|
Show version number
|
|
|
|
|
|
|
|
Environment Variables:
|
|
|
|
OPENREFINE_URL
|
|
|
|
URL to OpenRefine server
|
|
|
|
Default: http://localhost:3333
|
|
|
|
|
|
|
|
Examples:
|
2022-04-20 12:27:53 +02:00
|
|
|
orcli import csv "https://git.io/fj5hF" --projectName "duplicates"
|
2022-03-25 11:13:59 +01:00
|
|
|
orcli list
|
2022-04-20 12:27:53 +02:00
|
|
|
orcli info "duplicates"
|
|
|
|
orcli export tsv "duplicates"
|
|
|
|
orcli export tsv "duplicates" --output "duplicates.tsv"
|
|
|
|
orcli batch \
|
|
|
|
import csv "https://git.io/fj5hF" --projectName "duplicates" \
|
|
|
|
info "duplicates" \
|
|
|
|
export tsv "duplicates"
|
2022-04-04 23:00:37 +02:00
|
|
|
|
|
|
|
https://github.com/opencultureconsulting/orcli
|
2022-03-25 11:13:59 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
## Development
|
|
|
|
|
|
|
|
orcli uses [bashly](https://github.com/DannyBen/bashly/) for generating the one-file script from files in the `src` directory
|
|
|
|
|
|
|
|
1. Install bashly (requires ruby)
|
|
|
|
|
|
|
|
```sh
|
|
|
|
gem install bashly
|
|
|
|
```
|
|
|
|
|
|
|
|
2. Edit code in [src](src) directory
|
|
|
|
|
2022-04-20 12:27:53 +02:00
|
|
|
3. Generate script
|
2022-03-25 11:13:59 +01:00
|
|
|
|
|
|
|
```sh
|
2022-10-04 23:19:18 +02:00
|
|
|
bashly generate --upgrade
|
2022-03-25 11:13:59 +01:00
|
|
|
```
|