i have a generic json file {"name":"foo","age":20}. I need to convert it in avro format in python 3.x. I tried using fastavro and avro-python3 but both libraries asking for schema. Is there any way to generate avro without schema?
The below code works fine. But I am not able to generate without schema.
import avro.schema
import json
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter
schema = avro.schema.Parse(open("C:\\wwm\\schema2.avsc").read())
print(schema)
with open("C:\\wwm\\data.json") as js:
x=json.load(js)
writer = DataFileWriter(open("C:\\wwm\\data.avro", "wb"), DatumWriter(),schema)
writer.append(x)
writer.close()
either in your worker config, or your new connector config
key.converter.schemas.enable=false
value.converter.schemas.enable=false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.