CorrelAid / CorrelAid/formtransform

[survey2ddi 1/6] xlsform2ddi CLI: emit the response-data CSV and a real caseQnty

Open
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Step 1 of 6 in this repo for the survey2ddi retirement. Plan: HANDOVER_SURVEY2DDI.md. No blockers — this is the smallest issue and it gates the deprecation notices in CorrelAid/survey2ddi.

Problem

buildDataCsv shipped in #8, but the CLI cannot reach it. cmdXlsform2ddi in src/cli.ts passes no submissions to buildDdiXml, so:

  • <caseQnty> is always 0
  • <fileDscr URI="data.csv"> names a file the CLI never writes
  • getting a data CSV requires writing TypeScript against the library

The Python kobo2ddi transform does both halves in one command. Until the CLI does too, nothing in survey2ddi can be deprecated.

What to add

formtransform xlsform2ddi form.xlsx -o codebook.xml --data responses.csv
# writes codebook.xml + data.csv (caseQnty = row count)
  • --data <path> — response records. Accept both shapes: a flat CSV (header row of question names) and Kobo's submissions JSON array (kobo2ddi pull writes submissions.json). Detect by extension, fall back to sniffing the first non-whitespace byte for [/{.
  • --data-out <path> — default: data.csv beside the XML output, matching the datasetFilename recorded in <fileDscr>. If --dataset-filename is also given, the default follows it, so the XML and the file on disk cannot disagree.
  • Wire the parsed records into buildDdiXml's submissions option so <caseQnty> is correct, and into buildDataCsv(extractVariables(...), submissions) for the CSV.
  • Writing to stdout: with --data and no -o, the XML goes to stdout and the CSV needs an explicit --data-out — erroring on that combination is fine, silently dropping the CSV is not.

Notes

  • select_multiple values are expected space-joined; that is what both Kobo exports produce and what buildDataCsv parses.
  • Submission keys may be bare question names or group/name paths — readCell in src/pipelines/xlsform2ddi/data.ts already accepts either.
  • lstsv2ddi needs the same flag, but its response keying is a separate port — see the LimeSurvey response-normalization issue.

Acceptance criteria

  • --data accepts a flat CSV and a Kobo submissions JSON array
  • <caseQnty> equals the record count
  • The written CSV's filename matches <fileDscr URI> / <fileName>
  • CSV header order equals <var name=""> order in the emitted XML (already guaranteed by buildDataCsv — assert it in a CLI-level test)
  • --help documents both new flags

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/cli.ts at cmdXlsform2ddi, then inspect buildDdiXml, buildDataCsv, extractVariables, and readCell in src/pipelines/xlsform2ddi/data.ts. Add CLI-level coverage for flat CSV and Kobo submissions JSON, output naming, caseQnty, and header order. Done means --data and --data-out are documented in --help and the XML and CSV are both written consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.