Need help extracting a schema to make use for an avro file in Python

0 votes
As per the question header, I am learning to use the Avro library. I am looking at original documentation for learning.

So basically, I have to read a AVRO file which is actually obtained from Java. But I did read that the schema is already present in the avro file then why is it that I need to specify a schema file separately for this purpose?

Also there is another package called fastvro which can extract the avro schema directly. Is it a design feature of Python that it has to be done manually?

Is there any automatic way to extract it or am I missing something here? All help is appreciated, cheers!
Jan 10 in Python by Anirudh
• 2,050 points
196 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hi, nice question.

So what I daily use is Python v3.4 and the Avro v1.7.7 (What do you use?)

And it is quite simple actually. For the schema file I suggest you use the following code I have written to help you out to print out the generated schema:

reader = avro.datafile.DataFileReader(open('file_name.avro',"rb"),avro.io.DatumReader())
schema = reader.meta
print(schema)

I hope this helps, let me know if you need anything else. Cheers!

answered Jan 10 by Nymeria
• 3,500 points

Related Questions In Python

0 votes
1 answer
0 votes
2 answers

Extracting data from a JSON file in Python

Here is what i found and was ...READ MORE

answered Nov 27, 2018 in Python by Rupali
3,952 views
0 votes
1 answer

how to exit a python script in an if statement

This works fine for me: while True: ...READ MORE

answered Sep 19, 2018 in Python by bug_seeker
• 14,970 points
222 views
0 votes
1 answer

In python how to test a string for a substring

if "ABCD" in "xxxxABCDyyyy": This can be used ...READ MORE

answered Oct 24, 2018 in Python by Priyaj
• 56,120 points
33 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
20 views
+4 votes
6 answers
0 votes
1 answer
0 votes
1 answer

How do I use urllib to see if a website is 404 or 200 in Python?

For Python 3, try doing this: import urllib.request, ...READ MORE

answered Nov 29, 2018 in Python by Nymeria
• 3,500 points

edited Dec 11, 2018 by Nymeria 123 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.