I have a lot of data files (almost 150) in binary structure created according the .proto scheme of Protocol Buffer. Is there any efficient solution how to merge all the files to just one big binary data file without losing any information?
If your scheme allows it, you could combine existing data.
message People {
repeated Person person = 1;
}
message Person {
required int32 id = 1;
required string name = 2;
optional string email = 3;
}
Two existing binary files conataining a Person, each.
person1.binperson2.binimport p_pb2
people = p_pb2.People()
people.person.add().ParseFromString(open("person1.bin", "rb").read())
people.person.add().ParseFromString(open("person2.bin", "rb").read())
with open("people.bin", "wb") as o:
o.write(people.SerializeToString())
Now the file people.bin contains a People instance including both Person instances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With