Python Avro on windows gives ord () expected character, but string of length 0 found

I am trying to write an Avro serialization file using Java and then read it when using Python on windows. I can write an Avro file using Java, but when I try to read it while using Python, I get the error "ord () character expected, but string with length 0 was found"

This is not an incomplete or non-dumpable file error, as I can read the file completely through Java and it reads fine.

This is not a major error with my python installation, as I can run fetch serialization / deserialization from the Avro Getting Started page: http://avro.apache.org/docs/current/gettingstartedpython.html

Any ideas what this might be.

+3


source to share


1 answer


I am answering this myself as I have seen several similar posts in various forms and none of them answered.

The problem was that I was opening my python file using "r" mode instead of "rb". This reads fine until it hits the byte with hex 0x1A, which is interpreted as end of file in windows. The solution is to open the file as binary.



(I would suggest that the Avro (Python) launch page changes to use binary mode files to avoid other people using it.)

+4


source







All Articles