final import csv tests and examples
This commit is contained in:
parent
99424d221d
commit
444fd0320b
9
orcli
9
orcli
|
@ -74,6 +74,7 @@ orcli_usage() {
|
||||||
printf " orcli transform \"duplicates\" \"https://git.io/fj5ju\"\n"
|
printf " orcli transform \"duplicates\" \"https://git.io/fj5ju\"\n"
|
||||||
printf " orcli export tsv \"duplicates\"\n"
|
printf " orcli export tsv \"duplicates\"\n"
|
||||||
printf " orcli export tsv \"duplicates\" --output \"duplicates.tsv\"\n"
|
printf " orcli export tsv \"duplicates\" --output \"duplicates.tsv\"\n"
|
||||||
|
printf " orcli delete \"duplicates\"\n"
|
||||||
printf " orcli run --interactive\n"
|
printf " orcli run --interactive\n"
|
||||||
printf " orcli run << EOF\n orcli import csv \"https://git.io/fj5hF\" --projectName \"duplicates\"\n orcli transform \"duplicates\" \"https://git.io/fj5ju\"\n orcli export tsv \"duplicates\"\n EOF\n"
|
printf " orcli run << EOF\n orcli import csv \"https://git.io/fj5hF\" --projectName \"duplicates\"\n orcli transform \"duplicates\" \"https://git.io/fj5ju\"\n orcli export tsv \"duplicates\"\n EOF\n"
|
||||||
echo
|
echo
|
||||||
|
@ -165,7 +166,9 @@ orcli_delete_usage() {
|
||||||
# :command.usage_examples
|
# :command.usage_examples
|
||||||
printf "%s\n" "Examples:"
|
printf "%s\n" "Examples:"
|
||||||
printf " orcli delete \"duplicates\"\n"
|
printf " orcli delete \"duplicates\"\n"
|
||||||
|
printf " orcli delete \"duplicates\" --force\n"
|
||||||
printf " orcli delete 1234567890123\n"
|
printf " orcli delete 1234567890123\n"
|
||||||
|
printf " for p in $(orcli list); do orcli delete ${p:0:13}; done\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -343,7 +346,7 @@ orcli_import_csv_usage() {
|
||||||
printf " orcli import csv \"file1\" \"file2\"\n"
|
printf " orcli import csv \"file1\" \"file2\"\n"
|
||||||
printf " head -n 100 \"file\" | orcli import csv\n"
|
printf " head -n 100 \"file\" | orcli import csv\n"
|
||||||
printf " orcli import csv \"https://git.io/fj5hF\"\n"
|
printf " orcli import csv \"https://git.io/fj5hF\"\n"
|
||||||
printf " orcli import csv \"file\" \\\\\n --separator \";\" \\\\\n --encoding \"ISO-8859-1\" \\\\\n --trimStrings \\\\\n --projectName \"duplicates\"\n"
|
printf " orcli import csv \"file\" \\\\\n --separator \";\" \\\\\n --columnNames \"foo,bar,baz\" \\\\\n --ignoreLines 1 \\\\\n --encoding \"ISO-8859-1\" \\\\\n --limit 100 \\\\\n --trimStrings \\\\\n --projectName \"duplicates\"\n --projectTags \"test,urgent\"\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -481,7 +484,7 @@ orcli_import_tsv_usage() {
|
||||||
printf " orcli import tsv \"file1\" \"file2\"\n"
|
printf " orcli import tsv \"file1\" \"file2\"\n"
|
||||||
printf " head -n 100 \"file\" | orcli import tsv\n"
|
printf " head -n 100 \"file\" | orcli import tsv\n"
|
||||||
printf " orcli import tsv \"https://git.io/fj5hF\"\n"
|
printf " orcli import tsv \"https://git.io/fj5hF\"\n"
|
||||||
printf " orcli import tsv \"file\" \\\\\n --separator \";\" \\\\\n --encoding \"ISO-8859-1\" \\\\\n --trimStrings \\\\\n --projectName \"duplicates\"\n"
|
printf " orcli import tsv \"file\" \\\\\n --separator \";\" \\\\\n --columnNames \"foo,bar,baz\" \\\\\n --ignoreLines 1 \\\\\n --encoding \"ISO-8859-1\" \\\\\n --limit 100 \\\\\n --trimStrings \\\\\n --projectName \"duplicates\"\n --projectTags \"test,urgent\"\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -554,6 +557,7 @@ orcli_info_usage() {
|
||||||
printf "%s\n" "Examples:"
|
printf "%s\n" "Examples:"
|
||||||
printf " orcli info \"duplicates\"\n"
|
printf " orcli info \"duplicates\"\n"
|
||||||
printf " orcli info 1234567890123\n"
|
printf " orcli info 1234567890123\n"
|
||||||
|
printf " orcli info \"duplicates\" | jq -r .columns[]\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -733,6 +737,7 @@ orcli_export_tsv_usage() {
|
||||||
printf "%s\n" "Examples:"
|
printf "%s\n" "Examples:"
|
||||||
printf " orcli export tsv \"duplicates\"\n"
|
printf " orcli export tsv \"duplicates\"\n"
|
||||||
printf " orcli export tsv \"duplicates\" --output \"duplicates.tsv\"\n"
|
printf " orcli export tsv \"duplicates\" --output \"duplicates.tsv\"\n"
|
||||||
|
printf " orcli export tsv \"duplicates\" --encoding \"ISO-8859-1\"\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -19,6 +19,7 @@ examples:
|
||||||
- orcli transform "duplicates" "https://git.io/fj5ju"
|
- orcli transform "duplicates" "https://git.io/fj5ju"
|
||||||
- orcli export tsv "duplicates"
|
- orcli export tsv "duplicates"
|
||||||
- orcli export tsv "duplicates" --output "duplicates.tsv"
|
- orcli export tsv "duplicates" --output "duplicates.tsv"
|
||||||
|
- orcli delete "duplicates"
|
||||||
- orcli run --interactive
|
- orcli run --interactive
|
||||||
- |-
|
- |-
|
||||||
orcli run << EOF
|
orcli run << EOF
|
||||||
|
@ -50,7 +51,9 @@ commands:
|
||||||
help: suppress log output, print errors only
|
help: suppress log output, print errors only
|
||||||
examples:
|
examples:
|
||||||
- orcli delete "duplicates"
|
- orcli delete "duplicates"
|
||||||
|
- orcli delete "duplicates" --force
|
||||||
- orcli delete 1234567890123
|
- orcli delete 1234567890123
|
||||||
|
- for p in $(orcli list); do orcli delete ${p:0:13}; done
|
||||||
|
|
||||||
- name: import
|
- name: import
|
||||||
help: commands to create OpenRefine projects from files or URLs
|
help: commands to create OpenRefine projects from files or URLs
|
||||||
|
@ -145,9 +148,13 @@ commands:
|
||||||
- |-
|
- |-
|
||||||
orcli import csv "file" \\\\
|
orcli import csv "file" \\\\
|
||||||
--separator ";" \\\\
|
--separator ";" \\\\
|
||||||
|
--columnNames "foo,bar,baz" \\\\
|
||||||
|
--ignoreLines 1 \\\\
|
||||||
--encoding "ISO-8859-1" \\\\
|
--encoding "ISO-8859-1" \\\\
|
||||||
|
--limit 100 \\\\
|
||||||
--trimStrings \\\\
|
--trimStrings \\\\
|
||||||
--projectName "duplicates"
|
--projectName "duplicates"
|
||||||
|
--projectTags "test,urgent"
|
||||||
|
|
||||||
- name: tsv
|
- name: tsv
|
||||||
help: import tab-separated values (TSV)
|
help: import tab-separated values (TSV)
|
||||||
|
@ -179,9 +186,13 @@ commands:
|
||||||
- |-
|
- |-
|
||||||
orcli import tsv "file" \\\\
|
orcli import tsv "file" \\\\
|
||||||
--separator ";" \\\\
|
--separator ";" \\\\
|
||||||
|
--columnNames "foo,bar,baz" \\\\
|
||||||
|
--ignoreLines 1 \\\\
|
||||||
--encoding "ISO-8859-1" \\\\
|
--encoding "ISO-8859-1" \\\\
|
||||||
|
--limit 100 \\\\
|
||||||
--trimStrings \\\\
|
--trimStrings \\\\
|
||||||
--projectName "duplicates"
|
--projectName "duplicates"
|
||||||
|
--projectTags "test,urgent"
|
||||||
|
|
||||||
- name: list
|
- name: list
|
||||||
help: list projects on OpenRefine server
|
help: list projects on OpenRefine server
|
||||||
|
@ -193,6 +204,7 @@ commands:
|
||||||
examples:
|
examples:
|
||||||
- orcli info "duplicates"
|
- orcli info "duplicates"
|
||||||
- orcli info 1234567890123
|
- orcli info 1234567890123
|
||||||
|
- orcli info "duplicates" | jq -r .columns[]
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
help: run functional tests on tmp OpenRefine workspace
|
help: run functional tests on tmp OpenRefine workspace
|
||||||
|
@ -232,6 +244,7 @@ commands:
|
||||||
examples:
|
examples:
|
||||||
- orcli export tsv "duplicates"
|
- orcli export tsv "duplicates"
|
||||||
- orcli export tsv "duplicates" --output "duplicates.tsv"
|
- orcli export tsv "duplicates" --output "duplicates.tsv"
|
||||||
|
- orcli export tsv "duplicates" --encoding "ISO-8859-1"
|
||||||
|
|
||||||
- name: run
|
- name: run
|
||||||
help: run tmp OpenRefine workspace and execute shell script(s)
|
help: run tmp OpenRefine workspace and execute shell script(s)
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
t="import-csv-projectTags"
|
||||||
|
|
||||||
|
# create tmp directory
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
|
||||||
|
|
||||||
|
# input
|
||||||
|
cp data/example.csv "${tmpdir}/${t}.csv"
|
||||||
|
|
||||||
|
# assertion
|
||||||
|
cat << "DATA" > "${tmpdir}/${t}.assert"
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
baz
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# action
|
||||||
|
cd "${tmpdir}" || exit 1
|
||||||
|
orcli import csv "${t}.csv" --projectName "${t}" --projectTags "foo,bar,baz"
|
||||||
|
orcli info "${t}" | jq -r .tags[] > "${t}.output"
|
||||||
|
|
||||||
|
# test
|
||||||
|
diff -u "${t}.assert" "${t}.output"
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
t="import-csv-quiet"
|
||||||
|
|
||||||
|
# create tmp directory
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
|
||||||
|
|
||||||
|
# input
|
||||||
|
cp data/example.csv "${tmpdir}/${t}.csv"
|
||||||
|
|
||||||
|
# assertion (empty file)
|
||||||
|
touch "${tmpdir}/${t}.assert"
|
||||||
|
|
||||||
|
# action
|
||||||
|
cd "${tmpdir}" || exit 1
|
||||||
|
orcli import csv "${t}.csv" --projectName "${t}" --quiet &> "${t}.output"
|
||||||
|
|
||||||
|
# test
|
||||||
|
diff -u "${t}.assert" "${t}.output"
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
t="import-csv-skipBlankRows"
|
||||||
|
|
||||||
|
# create tmp directory
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
|
||||||
|
|
||||||
|
# input
|
||||||
|
cat << "DATA" > "${tmpdir}/${t}.csv"
|
||||||
|
a,b,c
|
||||||
|
1,2,3
|
||||||
|
,,
|
||||||
|
$,\,'
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# assertion
|
||||||
|
cat << "DATA" > "${tmpdir}/${t}.assert"
|
||||||
|
a b c
|
||||||
|
1 2 3
|
||||||
|
$ \ '
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# action
|
||||||
|
cd "${tmpdir}" || exit 1
|
||||||
|
orcli import csv "${t}.csv" --projectName "${t}" --skipBlankRows
|
||||||
|
orcli export tsv "${t}" > "${t}.output"
|
||||||
|
|
||||||
|
# test
|
||||||
|
diff -u "${t}.assert" "${t}.output"
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
t="import-csv-skipDataLines"
|
||||||
|
|
||||||
|
# create tmp directory
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
|
||||||
|
|
||||||
|
# input
|
||||||
|
cat << "DATA" > "${tmpdir}/${t}.csv"
|
||||||
|
a,b,c
|
||||||
|
1,2,3
|
||||||
|
0,0,0
|
||||||
|
$,\,'
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# assertion
|
||||||
|
cat << "DATA" > "${tmpdir}/${t}.assert"
|
||||||
|
a b c
|
||||||
|
0 0 0
|
||||||
|
$ \ '
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# action
|
||||||
|
cd "${tmpdir}" || exit 1
|
||||||
|
orcli import csv "${t}.csv" --projectName "${t}" --skipDataLines 1
|
||||||
|
orcli export tsv "${t}" > "${t}.output"
|
||||||
|
|
||||||
|
# test
|
||||||
|
diff -u "${t}.assert" "${t}.output"
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
t="import-csv-trimStrings"
|
||||||
|
|
||||||
|
# create tmp directory
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
|
||||||
|
|
||||||
|
# input
|
||||||
|
cat << "DATA" > "${tmpdir}/${t}.csv"
|
||||||
|
a,b,c
|
||||||
|
1 , 2 , 3
|
||||||
|
0,0,0
|
||||||
|
$,\,'
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# assertion
|
||||||
|
cat << "DATA" > "${tmpdir}/${t}.assert"
|
||||||
|
a b c
|
||||||
|
1 2 3
|
||||||
|
0 0 0
|
||||||
|
$ \ '
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# action
|
||||||
|
cd "${tmpdir}" || exit 1
|
||||||
|
orcli import csv "${t}.csv" --projectName "${t}" --trimStrings
|
||||||
|
orcli export tsv "${t}" > "${t}.output"
|
||||||
|
|
||||||
|
# test
|
||||||
|
diff -u "${t}.assert" "${t}.output"
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
t="import-csv-unicode biểu tượng cảm xúc ⛲"
|
||||||
|
|
||||||
|
# create tmp directory
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
|
||||||
|
|
||||||
|
# input
|
||||||
|
cat << "DATA" > "${tmpdir}/${t}.csv"
|
||||||
|
⌨,code,meaning
|
||||||
|
⛲,1F347,FOUNTAIN
|
||||||
|
⛳,1F349,FLAG IN HOLE
|
||||||
|
⛵,1F352,SAILBOAT
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# assertion
|
||||||
|
cat << "DATA" > "${tmpdir}/${t}.assert"
|
||||||
|
⌨ code meaning
|
||||||
|
⛲ 1F347 FOUNTAIN
|
||||||
|
⛳ 1F349 FLAG IN HOLE
|
||||||
|
⛵ 1F352 SAILBOAT
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# action
|
||||||
|
cd "${tmpdir}" || exit 1
|
||||||
|
orcli import csv "${t}.csv" --projectName "${t}"
|
||||||
|
orcli export tsv "${t}" > "${t}.output"
|
||||||
|
|
||||||
|
# test
|
||||||
|
diff -u "${t}.assert" "${t}.output"
|
Loading…
Reference in New Issue