CorrelAid / CorrelAid/formtransform
[survey2ddi 1/6] xlsform2ddi CLI: emit the response-data CSV and a real caseQnty
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 always0<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 pullwritessubmissions.json). Detect by extension, fall back to sniffing the first non-whitespace byte for[/{.--data-out <path>— default:data.csvbeside the XML output, matching thedatasetFilenamerecorded in<fileDscr>. If--dataset-filenameis also given, the default follows it, so the XML and the file on disk cannot disagree.- Wire the parsed records into
buildDdiXml'ssubmissionsoption so<caseQnty>is correct, and intobuildDataCsv(extractVariables(...), submissions)for the CSV. - Writing to stdout: with
--dataand 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_multiplevalues are expected space-joined; that is what both Kobo exports produce and whatbuildDataCsvparses.- Submission keys may be bare question names or
group/namepaths —readCellinsrc/pipelines/xlsform2ddi/data.tsalready accepts either. lstsv2ddineeds the same flag, but its response keying is a separate port — see the LimeSurvey response-normalization issue.
Acceptance criteria
-
--dataaccepts 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 bybuildDataCsv— assert it in a CLI-level test) -
--helpdocuments both new flags
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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