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, 2019 in Python by Anirudh
• 2,090 points
4,970 views

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"),avro.io.DatumReader())
schema = reader.meta
print(schema)

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

answered Jan 10, 2019 by Nymeria
• 3,560 points

Related Questions In Python

0 votes
1 answer

Need a python script to login into a website but username and password are in a txt file (Selenium automation script)

I had a similar requirement. I had ...READ MORE

answered Jan 31, 2019 in Python by Omkar
• 69,220 points
8,302 views
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, 2019 in Python by Tina
940 views
0 votes
1 answer

I want to download a file from the website by web scraping. Can anyone explain how to do this in jupyter lab (python) with an example?

Hey, Web scraping is a technique to automatically ...READ MORE

answered Apr 7, 2020 in Python by Gitika
• 65,770 points
2,378 views
0 votes
2 answers

How to use in python for loop not equal marks? example: a!=0

Hello @Azizjon, You can go through the example ...READ MORE

answered Oct 12, 2020 in Python by Gitika
• 65,770 points
2,261 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,422 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,042 views
0 votes
1 answer

Need help checking the validity of an image file in Python

I went through the Python documentation and ...READ MORE

answered Jan 18, 2019 in Python by Nymeria
• 3,560 points
2,281 views
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,560 points

edited Dec 11, 2018 by Nymeria 14,019 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP