Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python avro编写器不附加_Python_Python 3.x_Avro - Fatal编程技术网

Python avro编写器不附加

Python avro编写器不附加,python,python-3.x,avro,Python,Python 3.x,Avro,我想将XML文件中的数据存储在avro中。为了测试我的方案,我想向它写入少量数据。程序完成时没有出现错误,但是文件为空,因此没有附加任何数据 test.py import avro.schema from avro.datafile import DataFileReader, DataFileWriter from avro.io import DatumReader, DatumWriter schema = avro.schema.Parse(open("user.avsc").rea

我想将XML文件中的数据存储在avro中。为了测试我的方案,我想向它写入少量数据。程序完成时没有出现错误,但是文件为空,因此没有附加任何数据

test.py

import avro.schema
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter

 schema = avro.schema.Parse(open("user.avsc").read())
 writer = DataFileWriter(open("users.avro", "wb"), DatumWriter(), schema)
 writer.append({"count" : 5, "cvList" : {"id" : 5}})
 writer.close
user.avsc:

    {
  "name" : "cv",
  "type" : "record",
  "fields" : [
    {"name" : "count", "type" : "int"},
    {"name" : "cvList",
      "type": {
        "name" : "cvData",
        "type" : "record",
         "fields" : [
          {"name" : "id", "type" : "int"}
        ]
      }
    }
  ]
}
很抱歉,如果有明显的错误,我是avro和json新手。困扰我的是执行时没有错误

葛吕埃


马吕斯

那应该是作家吗?接近?这就解决了问题,谢谢: