fastavro: 'utf-8' codec can't decode byte 0xe2 in position 37: invalid continuation byte
I use python3.10.6 and fastavro(1.1.0 and 1.7.4) read avro ,code is below
from fastavro import reader
import sys
def read(avro_path: str):
with open(avro_path, 'rb') as fo:
for record in reader(fo):
yield record
records = read(sys.argv[1])
for record in records:
print(record)
then i get errors following
Traceback (most recent call last):
File "/home/a.py", line 10, in <module>
for record in records:
File "/home/a.py", line 6, in read
for record in reader(fo):
File "fastavro/_read.pyx", line 928, in _iter_avro_records
File "fastavro/_read.pyx", line 749, in fastavro._read._read_data
File "fastavro/_read.pyx", line 620, in fastavro._read.read_record
File "fastavro/_read.pyx", line 706, in fastavro._read._read_data
File "fastavro/_read.pyx", line 288, in fastavro._read.read_utf8
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 37: invalid continuation byte
some other avro arise following errors
Traceback (most recent call last):
File "/home/.py", line 10, in <module>
for record in records:
File "/home/a.py", line 6, in read
for record in reader(fo):
File "fastavro/_read.pyx", line 928, in _iter_avro_records
File "fastavro/_read.pyx", line 749, in fastavro._read._read_data
File "fastavro/_read.pyx", line 620, in fastavro._read.read_record
File "fastavro/_read.pyx", line 722, in fastavro._read._read_data
File "fastavro/_read.pyx", line 381, in fastavro._read.read_array
File "fastavro/_read.pyx", line 749, in fastavro._read._read_data
File "fastavro/_read.pyx", line 620, in fastavro._read.read_record
File "fastavro/_read.pyx", line 706, in fastavro._read._read_data
File "fastavro/_read.pyx", line 288, in fastavro._read.read_utf8
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x98 in position 15: invalid start byte
but I use java tool: avro-tools-1.10.1.jar https://repo1.maven.org/maven2/org/apache/avro/avro-tools/1.10.1/ all is ok
and I read issue:https://github.com/fastavro/fastavro/issues/392 do any one have ideas? thanks
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18
@91Eric https://github.com/fastavro/fastavro/pull/696 should resolve this. With that change you will be able to do one of the following:
reader = fastavro.reader(fp, handle_unicode_errors="replace")if you want to get the�anytime there is a invalid unicode characterreader = fastavro.reader(fp, handle_unicode_errors="ignore")if you want to just ignore the invalid unicode character