How to read and manipulate Avro schema (avsc format)

3.1k Views Asked by At

I want to use the Avro schema and read it in python. Cannot read the schema. It is throwing an error

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

schema = avro.schema.Parse(open("user.avsc","rb").read())
schema_1=schema.meta
print(schema_1)
1

There are 1 best solutions below

1
On

Are you trying to read the fields in the schema (user.avsc) ? If so: schema would be a list of all the fields in the avsc file [each.name for each in schema] would give the list of fields.

Hope that helps...