diff --git a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py index 446476971151e..8b30caed0e166 100644 --- a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py +++ b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py @@ -8,6 +8,40 @@ # For the list of contributors see $ROOTSYS/README/CREDITS. # ################################################################################ +r""" +\pythondoc RNTupleWriter + +RNTupleWriter is an interface to write RNTuples to storage. + +A simple way to write an RNTuple in python is by: +- creating a model and adding fields to it +- opening an RNTupleWriter +- creating entries and filling them with data +- committing entries to the RNTuple via writer.Fill(entry) + +\code{.py} +import ROOT + +# Create the model +model = ROOT.RNTupleModel.Create() + +# Define the schema by adding fields to the model. +model.MakeField['int']("foo") + +# Create a writer as a context manager +with ROOT.RNTupleWriter.Recreate(model, "myNtuple", "file.root") as writer: + # create entries and write them to the RNTuple + for i in range(0,10): + entry = writer.CreateEntry() + entry['foo'] = i + writer.Fill(entry) +# On destruction, the writer will flush the written data to disk + +\endcode + +\endpythondoc +""" + from . import pythonization from ._pyz_utils import MethodTemplateGetter, MethodTemplateWrapper