improve error handling
This commit is contained in:
parent
be57685be2
commit
b156066112
|
@ -76,7 +76,7 @@ Optional:
|
|||
3. Remove duplicates by applying an undo/redo JSON file
|
||||
|
||||
```sh
|
||||
orcli transform "duplicates" "https://git.io/fj5hF"
|
||||
orcli transform "duplicates" "https://git.io/fj5ju"
|
||||
```
|
||||
|
||||
4. Export data from OpenRefine project to tab-separated-values (TSV) file `duplicates.tsv`
|
||||
|
|
9
orcli
9
orcli
|
@ -887,10 +887,17 @@ orcli_transform_command() {
|
|||
# support multiple files
|
||||
for i in "${!files[@]}"; do
|
||||
# read each operation into one line
|
||||
mapfile -t jsonlines < <(jq -c '.[]' "${files[$i]}")
|
||||
if json="$(jq -c '.[]' "${files[$i]}")"; then
|
||||
mapfile -t jsonlines <<<"$json"
|
||||
else
|
||||
error "parsing ${files[$i]} failed!"
|
||||
fi
|
||||
for line in "${jsonlines[@]}"; do
|
||||
# parse one line/operation into array
|
||||
declare -A data="($(echo "$line" | jq -r 'to_entries | map("[\(.key)]=" + @sh "\(.value|tostring)") | .[]'))"
|
||||
if [[ ! ${data[op]} ]]; then
|
||||
error "parsing ${files[$i]} failed!"
|
||||
fi
|
||||
# map operation names to command endpoints
|
||||
# https://github.com/OpenRefine/OpenRefine/blob/master/main/webapp/modules/core/MOD-INF/controller.js
|
||||
com="${data[op]#core/}"
|
||||
|
|
|
@ -29,10 +29,17 @@ done
|
|||
# support multiple files
|
||||
for i in "${!files[@]}"; do
|
||||
# read each operation into one line
|
||||
mapfile -t jsonlines < <(jq -c '.[]' "${files[$i]}")
|
||||
if json="$(jq -c '.[]' "${files[$i]}")"; then
|
||||
mapfile -t jsonlines <<<"$json"
|
||||
else
|
||||
error "parsing ${files[$i]} failed!"
|
||||
fi
|
||||
for line in "${jsonlines[@]}"; do
|
||||
# parse one line/operation into array
|
||||
declare -A data="($(echo "$line" | jq -r 'to_entries | map("[\(.key)]=" + @sh "\(.value|tostring)") | .[]'))"
|
||||
if [[ ! ${data[op]} ]]; then
|
||||
error "parsing ${files[$i]} failed!"
|
||||
fi
|
||||
# map operation names to command endpoints
|
||||
# https://github.com/OpenRefine/OpenRefine/blob/master/main/webapp/modules/core/MOD-INF/controller.js
|
||||
com="${data[op]#core/}"
|
||||
|
|
Loading…
Reference in New Issue