Search code examples
pythoncsvprotocol-buffers

Creating a Protobuf file from CSV


Good day everyone. I need to create a simple file in Protobuf (proto) format, preferably using Python (I'm currently using PyCharm). It should be very simple and resemble the following CSV structure:

header = ['Surname', 'Name'] data = ['John', 'Doe']

If anyone knows how to do it, it would help me a lot. Thanks!

I have already transformed this CSV structure into a Parquet file and tried doing the same for Protobuf, but it didn't work.


Solution

  • What issues have you faced?

    syntax="proto3";
    
    message Data {
      string surname = 1;
      string name = 2;
    }
    
    message CSV {
      repeated Data data = 1;
    }
    

    or

    syntax="proto3";
    
    message Data {
      string data1 = 1;
      string data2 = 2;
    }
    
    message CSV {
      string header1 = 1;
      string header2 = 2;
      repeated Data data = 3;
    }