Added OFModel class to write fields
This commit is contained in:
parent
ef2e23ab15
commit
62af6a03ed
2 changed files with 26 additions and 14 deletions
21
olaflow/processing/olaflow.py
Normal file
21
olaflow/processing/olaflow.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
import re
|
||||
|
||||
|
||||
class OFModel:
|
||||
def __init__(self, root):
|
||||
self._root = root
|
||||
|
||||
def write_field(self, field, values):
|
||||
with open(self._root.joinpath("0", field), "r") as aw_file:
|
||||
aw_raw = aw_file.read()
|
||||
|
||||
with open(self._root.joinpath("0", field), "w") as aw_file:
|
||||
aw_file.write(
|
||||
re.sub(
|
||||
r"(?<=\(\n).*?(?=\n\))",
|
||||
"\n".join(values.astype(str)),
|
||||
aw_raw,
|
||||
count=1,
|
||||
flags=re.S,
|
||||
)
|
||||
)
|
Reference in a new issue