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,070 points

1 answer to this question.

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"),
schema = reader.meta

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

answered Jan 10 by Nymeria
• 3,520 points

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

Need help to open excel file and read in Python

You can use pandas module to do ...READ MORE

answered Jul 22 in Python by Tina
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
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
• 15,350 points
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 278 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,520 points

edited Dec 11, 2018 by Nymeria 806 views