Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import csv #1

Closed
felixlohmeier opened this issue Mar 25, 2022 · 4 comments · Fixed by #19
Closed

import csv #1

felixlohmeier opened this issue Mar 25, 2022 · 4 comments · Fixed by #19
Assignees
Labels
enhancement New feature or request

Comments

@felixlohmeier
Copy link
Member

felixlohmeier commented Mar 25, 2022

args: file(s) or url(s)
out: project id

@felixlohmeier
Copy link
Member Author

@felixlohmeier felixlohmeier added this to the 0.2.0 proof of concept milestone Mar 25, 2022
@felixlohmeier felixlohmeier added the enhancement New feature or request label Mar 25, 2022
@felixlohmeier
Copy link
Member Author

check if project contains at least one row (may be skipped to gain ~40ms)

local rows
rows=$(curl -fs --get \
  --data project="1234567890123" \
  --data limit=0 \
  "${OPENREFINE_URL}/command/core/get-rows" \
  | tr "," "\n" | grep total | cut -d ":" -f 2)
if [[ "$rows" = "0" ]]; then
  error "imported project contains 0 rows!"
fi

@felixlohmeier felixlohmeier self-assigned this Mar 30, 2022
@felixlohmeier
Copy link
Member Author

felixlohmeier commented Apr 2, 2022

bashly 0.7.9 introduces repeatable args. the following code snippet should support one or multiple files and non-blocking stdin:

bashly.yml

args:
- name: file
  help: Path to one or more files. When FILE is -, read standard input.
  default: "-"
  repeatable: true

command.sh

eval "files=(${args[file]})"

if [ "${files[*]}" = "-" ] && [ -t 0 ]; then
  printf "missing required argument or standard input\nusage: cli FILE...\n"
  exit 1
fi

This was referenced Apr 2, 2022
Closed
@felixlohmeier
Copy link
Member Author

first draft:
https://github.com/opencultureconsulting/orcli/tree/felixlohmeier/import-csv-1

remaining todo:

  • support multiple file(s)
  • support URL(s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

1 participant