Let's say I am given a yaml file called "label.yaml"
id: 1
color: red
toy: car
I want to make 10000 copies of this file with id
being the ONLY value that changes and all it has to do is change incrementally.
id: 1
color: red
toy: car
id: 2
color: red
toy: car
id: 3
color: red
toy: car
... And so on...
Something I've tried:
import yaml
with open("data.yaml") as f:
data = yaml.safe_load(f)
for i in range(1,100001):
data["id"] = i
with open(f"data-{i}.yaml", "w+") as f:
yaml.dump(data, f)
Is there a more efficient way to do this?