Plan a spreadsheet import with an AI assistant
5 minute read
An AI assistant can inspect an unfamiliar spreadsheet and draft R code to reshape, validate, and import it. Treat the result as a proposed workflow, not as validated data. Never paste an API token, password, sensitive coordinates, personal data, or unpublished data into a service not approved for those data. Preserve an immutable source copy and review all generated code.
Prompt template
Attach the CSV or XLSX and replace the bracketed text. If attachments cannot be read, provide sheet names, column names, and a small de-identified sample.
Help me prepare a reproducible, auditable import into OpenDataBio using R and
the opendatabio R package.
Assume I am a beginner in R and data organization. I am using an ordinary
online chatbot, possibly a free one, which cannot run R, may not retain files
between conversations, and may limit messages. Do not assume I know terminals,
RStudio projects, working directories, packages, or OpenDataBio objects. Use
plain language and explain technical terms when they first appear.
File: attached. API base URL: [URL]. Destination project: [name or ID]. Dataset:
[name or ID]. The data describe [description]. One row represents [meaning].
[Add known units, codes, missing-value conventions, and expected geographic or
taxonomic scope.]
Use these official sources as the required technical context:
- OpenDataBio documentation: https://opendatabio.gitlab.io/docs/
- API overview: https://opendatabio.gitlab.io/docs/api/
- POST fields and endpoint rules: https://opendatabio.gitlab.io/docs/api/post-data/
- Data-import workflow: https://opendatabio.gitlab.io/docs/guides/data-import-workflow/
- R import tutorials: https://opendatabio.gitlab.io/docs/tutorials/02-post-data-r-vignette/
- OpenDataBio-R source and README: https://gitlab.com/opendatabio/opendatabio-r
Open and consult those URLs before proposing code. Prefer them over general
knowledge or third-party examples. For each proposed odb_* function and each
API field, name the official page that supports it. If you cannot access a URL,
say so and ask me to provide its content; do not guess. Note any apparent
version mismatch between the server documentation and the R package.
Do not import anything yet. Never ask for or print my API token; use
Sys.getenv("ODB_TOKEN"). Do not invent IDs, matches, units, dates, coordinates,
or missing values. Mark uncertainty for my review.
First inspect every sheet and report its dimensions, candidate header row,
duplicate/blank columns, inferred types, missing-value codes, and a
de-identified sample. Explain what one row appears to represent and flag cells
or columns containing multiple entities.
Then propose a mapping table containing source column, OpenDataBio object and
field, transformation, required/optional status, confidence, and questions for
me. Verify fields against the OpenDataBio POST API and R-client documentation;
do not guess unsupported fields. Add a stable source_row_id and retain original
values beside normalized ones. Document every transformation.
Split the workbook into dependency tables. Search existing shared People,
References, Taxons, Locations, and Traits before creating anything; then handle
Project/Dataset relationships, Individuals/occurrences,
Vouchers/identifications, and finally Measurements/Media/vernacular names as
applicable. Produce explicit matched, unmatched, and ambiguous tables. Never
resolve an ambiguous match automatically or use row position as a key.
When coordinates exist, call locations-validation and flag invalid ranges,
swapped axes, unexpected geography, duplicates, and unsuitable precision
without silently correcting them.
Before any POST, run local validation and write mapping_review.csv,
validation_errors.csv, ambiguous_matches.csv, and import_plan.csv. Put every
write operation behind RUN_IMPORT <- FALSE; when FALSE, no POST or PUT may run.
After I approve the plan, import a representative pilot batch, save every
UserJob ID, poll safely, download row-level results, and join them by
source_row_id while retaining odb_status, odb_id, odb_uuid, odb_error, and
odb_warning. Stop dependent stages if prerequisites fail; retry only corrected
pending rows; never delete or overwrite records. GET created or reused records
to verify essential fields and counts, then write a reconciliation report and
sessionInfo().
Organize the result as 00_config.R, 01_inspect.R, 02_transform.R,
03_match_validate.R, 04_pilot_import.R, 05_full_import.R, and 06_verify.R, with
dependencies and run instructions.
In addition to the scripts, produce a beginner's step-by-step operating guide.
Start with installing R and RStudio, installing or updating packages, creating
a dedicated import folder, placing the spreadsheet there, and configuring
ODB_TOKEN safely. Give only complete commands that I can copy and paste. Say
exactly which program, file, or console receives each command; never use vague
instructions such as "configure the environment" or "run the script".
Present one stage at a time in this order: purpose; files read or created; exact
copyable block; how to run it; expected result; how to tell whether it worked;
common errors and fixes; and a stopping point. At the end of each stage, ask me
to paste only the error message or generated summary and wait for confirmation
before continuing. Never ask me to paste a token, sensitive data, or the entire
table. If the conversation loses context, provide a short handoff summary that
I can paste into a new conversation.
Never tell me to run all scripts at once. Stages 01 through 03 and a
RUN_IMPORT <- FALSE test must finish before the pilot. Before the first POST,
show a plain-language checklist and require explicit confirmation. Require a
second confirmation before the full import, after pilot review. Explain how to
stop safely, resume later, and find all review and result files.
Before writing scripts, show: (a) your workbook interpretation, (b) dependency
order and proposed mapping, (c) assumptions and ambiguities, and (d) questions
I must answer. Wait for my answers before finalizing low-confidence mappings.
Run the generated workflow first with RUN_IMPORT <- FALSE, then as a small
pilot. Confirm that proposed functions exist in the installed OpenDataBio-R
version and agree with the server’s POST API. A
successful UserJob can still contain warnings or reused records, so reconcile
every row before continuing. See also the data import
workflow.