Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions for ch03/python/test_avro.py #20

Open
JBPressac opened this issue Jan 11, 2014 · 0 comments
Open

Suggestions for ch03/python/test_avro.py #20

JBPressac opened this issue Jan 11, 2014 · 0 comments

Comments

@JBPressac
Copy link

Hello,
On page 41 in the O'Reilly book, the file (test_avro.py) given as Example 3-2 has the same name as the file to write avros in Python given as Example 3-1.

What is more, the OUTFILE_NAME intialisation is missing. Here is the script (I named it test_reading_avro.py) with the suggested correction:

from avro import schema, datafile, io
import pprint
# Test reading avros
rec_reader = io.DatumReader()

# Create a 'data file' (avro file) reader
OUTFILE_NAME = '/tmp/messages.avro'
df_reader = datafile.DataFileReader( open(OUTFILE_NAME), rec_reader)

# Read all records stored inside
pp = pprint.PrettyPrinter()
for record in df_reader:
    pp.pprint(record)

What is more, I run those scripts on Mac OS X, but they won't work on Microsoft Windows which has no /tmp directory.

Jean-Baptiste

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant