【问题标题】:Creating a Protobuf file from CSV从 CSV 创建 Protobuf 文件
【发布时间】:2022-11-29 05:42:13
【问题描述】:
今天是个好日子。我需要创建一个 Protobuf (proto) 格式的简单文件,最好使用 Python(我目前正在使用 PyCharm)。它应该非常简单并且类似于以下 CSV 结构:
header = ['姓氏', '姓名']
数据 = ['约翰', '母鹿']
如果有人知道该怎么做,那会对我有很大帮助。谢谢!
我已经将此 CSV 结构转换为 Parquet 文件并尝试对 Protobuf 执行相同的操作,但没有成功。
【问题讨论】:
标签:
python
csv
protocol-buffers
【解决方案1】:
你遇到过什么问题?
syntax="proto3";
message Data {
string surname = 1;
string name = 2;
}
message CSV {
repeated Data data = 1;
}
或者
syntax="proto3";
message Data {
string data1 = 1;
string data2 = 2;
}
message CSV {
string header1 = 1;
string header2 = 2;
repeated Data data = 3;
}