Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
_rntuple.pyzdoc
Go to the documentation of this file.
1\pythondoc RNTupleWriter
3RNTupleWriter is an interface to write RNTuples to storage.
4
5A simple way to write an RNTuple in python is by:
6- creating a model and adding fields to it
7- opening an RNTupleWriter
8- creating entries and filling them with data
9- committing entries to the RNTuple via writer.Fill(entry)
10
11\code{.py}
12import ROOT
13
14# Create the model
15model = ROOT.RNTupleModel.Create()
16
17# Define the schema by adding fields to the model.
18model.MakeField['int']("foo")
19
20# Create a writer as a context manager
21with ROOT.RNTupleWriter.Recreate(model, "myNtuple", "file.root") as writer:
22 # create an entry and use it to write data to the RNTuple
23 entry = writer.CreateEntry()
24 for i in range(0,10):
25 entry['foo'] = i
26 writer.Fill(entry)
27# On destruction, the writer will flush the written data to disk
28
29\endcode
30
31\endpythondoc
#define a(i)
Definition RSha256.hxx:99
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
An RNTuple that gets filled with entries (data) and writes them to storage.
static std::unique_ptr< RNTupleWriter > Recreate(std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Creates an RNTupleWriter backed by storage, overwriting it if one with the same URI exists.