ddi-l¶
ddi-l is a Python library for creating, reading, updating and validating
DDI Lifecycle 3.3
XML documents. You work with studies, questions and variables as Python
objects, and ddi-l writes and checks the XML.
Quick start¶
import ddi_l as ddi
# Create a new study
doc = ddi.new_study(title="Household Survey", agency="example.org")
# Add questions
q = doc.add_question(text="How old are you?")
# Add variables linked to questions
doc.add_variable(name="Age", question=q)
# Save to XML
doc.save("household-survey.xml")
# Open an existing study
doc = ddi.open_ddi("household-survey.xml")
for v in doc.variables:
print(v.identifier)
Install¶
Install ddi-l with pip or Poetry. The full extra adds the faster lxml
backend (see Installation).
Where to go next¶
-
Install
Install the package with
piporpoetryand check that it works. -
Validate
Validate documents against the DDI schemas, run the lint rules, and add the checks to CI.
-
Author
Build DDI documents step by step with the CRUD API.
-
Use the CLI
Validate, round-trip and convert files with the
ddicommand.
The site also has a 16-module training curriculum, an API reference and a models reference. To contribute, see the development guide and the contributor guide.